OLD | NEW |
1 /* | 1 /* |
2 * ChartNew.js | 2 * ChartNew.js |
3 * | 3 * |
4 * Vancoppenolle Francois - January 2014 | 4 * Vancoppenolle Francois - January 2014 |
5 * francois.vancoppenolle@favomo.be | 5 * francois.vancoppenolle@favomo.be |
6 * | 6 * |
7 * Source location : http:\\www.favomo.be\graphjs | 7 * Source location : http:\\www.favomo.be\graphjs |
8 * GitHub community : https://github.com/FVANCOP/ChartNew.js | 8 * GitHub community : https://github.com/FVANCOP/ChartNew.js |
9 * | 9 * |
10 * This file is an adaptation of the chart.js source developped by Nick Downie (
2013) | 10 * This file is an adaptation of the chart.js source developped by Nick Downie (
2013) |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 String.prototype.trim = function() { | 630 String.prototype.trim = function() { |
631 return this.replace(/^\s+|\s+$/g, ''); | 631 return this.replace(/^\s+|\s+$/g, ''); |
632 } | 632 } |
633 }; | 633 }; |
634 //}; | 634 //}; |
635 var dynamicDisplay = new Array(); | 635 var dynamicDisplay = new Array(); |
636 var dynamicDisplayList = new Array(); | 636 var dynamicDisplayList = new Array(); |
637 | 637 |
638 function dynamicFunction(data, config, ctx) { | 638 function dynamicFunction(data, config, ctx) { |
639 | 639 |
| 640 if (isIE() < 9 && isIE() != false) return(true); |
| 641 |
640 if (config.dynamicDisplay) { | 642 if (config.dynamicDisplay) { |
641 if (ctx.canvas.id == "") { | 643 if (ctx.canvas.id == "") { |
642 var cvdate = new Date(); | 644 var cvdate = new Date(); |
643 var cvmillsec = cvdate.getTime(); | 645 var cvmillsec = cvdate.getTime(); |
644 ctx.canvas.id = "Canvas_" + cvmillsec; | 646 ctx.canvas.id = "Canvas_" + cvmillsec; |
645 } | 647 } |
646 if (typeof(dynamicDisplay[ctx.canvas.id]) == "undefined") { | 648 if (typeof(dynamicDisplay[ctx.canvas.id]) == "undefined") { |
647 dynamicDisplayList[dynamicDisplayList["length"]] = ctx.c
anvas.id; | 649 dynamicDisplayList[dynamicDisplayList["length"]] = ctx.c
anvas.id; |
648 dynamicDisplay[ctx.canvas.id] = [ctx, false, false, data
, config, ctx.canvas]; | 650 dynamicDisplay[ctx.canvas.id] = [ctx, false, false, data
, config, ctx.canvas]; |
649 dynamicDisplay[ctx.canvas.id][1] = isScrolledIntoView(ct
x.canvas); | 651 dynamicDisplay[ctx.canvas.id][1] = isScrolledIntoView(ct
x.canvas); |
(...skipping 2675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3325 } | 3327 } |
3326 } | 3328 } |
3327 for (var i = 0; i < data.datasets.length; i++) { | 3329 for (var i = 0; i < data.datasets.length; i++) { |
3328 if (animPc >= 1) { | 3330 if (animPc >= 1) { |
3329 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | 3331 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); |
3330 else lgtxt = ""; | 3332 else lgtxt = ""; |
3331 } | 3333 } |
3332 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 3334 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
3333 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; | 3335 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; |
3334 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; | 3336 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; |
3335 » » » » » if (i == 0) { | 3337 » » » » » if (typeof tempp[j]=="undefined") { |
3336 tempp[j]=0; | 3338 tempp[j]=0; |
3337 tempn[j]=0; | 3339 tempn[j]=0; |
3338 zeroY= calculateOffset(config.l
ogarithmic, 0 , calculatedScale, scaleHop); | 3340 zeroY= calculateOffset(config.l
ogarithmic, 0 , calculatedScale, scaleHop); |
3339 } | 3341 } |
3340 var barOffset = yAxisPosX + config.barVa
lueSpacing + valueHop * j; | 3342 var barOffset = yAxisPosX + config.barVa
lueSpacing + valueHop * j; |
3341 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined') && 1*data.datasets[i].data[j] != 0 ) { | 3343 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined') && 1*data.datasets[i].data[j] != 0 ) { |
3342 if (1*data.datasets[i].data[j]<0
) { | 3344 if (1*data.datasets[i].data[j]<0
) { |
3343 var botval=tempp[j]; | 3345 var botval=tempp[j]; |
3344 var topval=tempp[j]+1*da
ta.datasets[i].data[j] ; | 3346 var topval=tempp[j]+1*da
ta.datasets[i].data[j] ; |
3345 } else { | 3347 } else { |
(...skipping 12 matching lines...) Expand all Loading... |
3358 ctx.fillStyle = config.defaultFi
llColor; | 3360 ctx.fillStyle = config.defaultFi
llColor; |
3359 if (typeof data.datasets[i].fill
Color == "function") ctx.fillStyle = data.datasets[i].fillColor("FILLCOLOR", dat
a, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "StackedBar", ctx,
barOffset, botBar , barOffset + barWidth, topBar); | 3361 if (typeof data.datasets[i].fill
Color == "function") ctx.fillStyle = data.datasets[i].fillColor("FILLCOLOR", dat
a, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "StackedBar", ctx,
barOffset, botBar , barOffset + barWidth, topBar); |
3360 else if (typeof(data.datasets[i]
.fillColor) == "string") { | 3362 else if (typeof(data.datasets[i]
.fillColor) == "string") { |
3361 ctx.fillStyle = data.dat
asets[i].fillColor; | 3363 ctx.fillStyle = data.dat
asets[i].fillColor; |
3362 } else if (typeof(data.datasets[
i].fillColor) == "object") { | 3364 } else if (typeof(data.datasets[
i].fillColor) == "object") { |
3363 if (typeof(data.datasets
[i].fillColor[0]) == "string") { | 3365 if (typeof(data.datasets
[i].fillColor[0]) == "string") { |
3364 ctx.fillStyle =
data.datasets[i].fillColor[Min([data.datasets[i].fillColor.length - 1, j])]; | 3366 ctx.fillStyle =
data.datasets[i].fillColor[Min([data.datasets[i].fillColor.length - 1, j])]; |
3365 } | 3367 } |
3366 } | 3368 } |
3367 ctx.strokeStyle = config.default
StrokeColor; | 3369 ctx.strokeStyle = config.default
StrokeColor; |
3368 » » » » » » if (typeof data.datasets[i].stro
keColor == "function") ctx.strokeStyle = data.datasets[i].strokeColor("STROKECOL
OR", data, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "StackedBa
r", ctx, barOffset, botBar, barOffset + barwidth, topBar); | 3370 » » » » » » if (typeof data.datasets[i].stro
keColor == "function") ctx.strokeStyle = data.datasets[i].strokeColor("STROKECOL
OR", data, config, i, j, currentAnimPc, 1 * data.datasets[i].data[j], "StackedBa
r", ctx, barOffset, botBar, barOffset + barWidth, topBar); |
3369 else if (typeof(data.datasets[i]
.strokeColor) == "string") { | 3371 else if (typeof(data.datasets[i]
.strokeColor) == "string") { |
3370 ctx.strokeStyle = data.d
atasets[i].strokeColor; | 3372 ctx.strokeStyle = data.d
atasets[i].strokeColor; |
3371 } else if (typeof(data.datasets[
i].strokeColor) == "object") { | 3373 } else if (typeof(data.datasets[
i].strokeColor) == "object") { |
3372 if (typeof(data.datasets
[i].strokeColor[0]) == "string") { | 3374 if (typeof(data.datasets
[i].strokeColor[0]) == "string") { |
3373 ctx.strokeStyle
= data.datasets[i].strokeColor[Min([data.datasets[i].strokeColor.length - 1, j])
]; | 3375 ctx.strokeStyle
= data.datasets[i].strokeColor[Min([data.datasets[i].strokeColor.length - 1, j])
]; |
3374 } | 3376 } |
3375 } | 3377 } |
3376 | 3378 |
3377 if(currentAnimPc !=0) { | 3379 if(currentAnimPc !=0) { |
3378 ctx.beginPath(); | 3380 ctx.beginPath(); |
(...skipping 17 matching lines...) Expand all Loading... |
3396 } | 3398 } |
3397 } | 3399 } |
3398 if (1*data.datasets[i].data[j]<0
) { | 3400 if (1*data.datasets[i].data[j]<0
) { |
3399 tempp[j]=tempp[j]+1*data
.datasets[i].data[j] ; | 3401 tempp[j]=tempp[j]+1*data
.datasets[i].data[j] ; |
3400 } else { | 3402 } else { |
3401 tempn[j]=tempn[j]+1*data
.datasets[i].data[j] ; | 3403 tempn[j]=tempn[j]+1*data
.datasets[i].data[j] ; |
3402 } | 3404 } |
3403 } | 3405 } |
3404 } | 3406 } |
3405 } | 3407 } |
| 3408 |
| 3409 var tempp = new Array(data.datasets.length); |
| 3410 var tempn = new Array(data.datasets.length); |
| 3411 |
3406 if (animPc >= 1 && config.inGraphDataShow) { | 3412 if (animPc >= 1 && config.inGraphDataShow) { |
3407 var yPos = 0, | 3413 var yPos = 0, |
3408 xPos = 0; | 3414 xPos = 0; |
3409 for (var i = 0; i < data.datasets.length; i++) { | 3415 for (var i = 0; i < data.datasets.length; i++) { |
3410 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 3416 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
3411 cumvalue[j] = 0; | 3417 cumvalue[j] = 0; |
3412 } | 3418 } |
3413 } | 3419 } |
3414 for (var i = 0; i < data.datasets.length; i++) { | 3420 for (var i = 0; i < data.datasets.length; i++) { |
3415 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | 3421 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); |
3416 else lgtxt = ""; | 3422 else lgtxt = ""; |
3417 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 3423 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
3418 » » » » » » if (i == 0) { | 3424 » » » » » » if (typeof tempp[j]=="undefined"
) { |
3419 tempp[j]=0; | 3425 tempp[j]=0; |
3420 tempn[j]=0; | 3426 tempn[j]=0; |
3421 zeroY= calculateOffset(
config.logarithmic, 0 , calculatedScale, scaleHop); | 3427 zeroY= calculateOffset(
config.logarithmic, 0 , calculatedScale, scaleHop); |
3422 } | 3428 } |
3423 if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { | 3429 if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { |
3424 if (1*data.datasets[i].d
ata[j]<0) { | 3430 if (1*data.datasets[i].d
ata[j]<0) { |
3425 var botval=tempp
[j]; | 3431 var botval=tempp
[j]; |
3426 var topval=tempp
[j]+1*data.datasets[i].data[j] ; | 3432 var topval=tempp
[j]+1*data.datasets[i].data[j] ; |
3427 } else { | 3433 } else { |
3428 var botval=tempn
[j]; | 3434 var botval=tempn
[j]; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3462 if (config.inGraphDataXP
osition == 1) { | 3468 if (config.inGraphDataXP
osition == 1) { |
3463 xPos = barOffset
+ config.inGraphDataPaddingX; | 3469 xPos = barOffset
+ config.inGraphDataPaddingX; |
3464 } else if (config.inGrap
hDataXPosition == 2) { | 3470 } else if (config.inGrap
hDataXPosition == 2) { |
3465 xPos = barOffset
+ barWidth / 2 + config.inGraphDataPaddingX; | 3471 xPos = barOffset
+ barWidth / 2 + config.inGraphDataPaddingX; |
3466 } else if (config.inGrap
hDataXPosition == 3) { | 3472 } else if (config.inGrap
hDataXPosition == 3) { |
3467 xPos = barOffset
+ barWidth + config.inGraphDataPaddingX; | 3473 xPos = barOffset
+ barWidth + config.inGraphDataPaddingX; |
3468 } | 3474 } |
3469 if (config.inGraphDataYP
osition == 1) { | 3475 if (config.inGraphDataYP
osition == 1) { |
3470 yPos = botBar -
config.inGraphDataPaddingY; | 3476 yPos = botBar -
config.inGraphDataPaddingY; |
3471 } else if (config.inGrap
hDataYPosition == 2) { | 3477 } else if (config.inGrap
hDataYPosition == 2) { |
3472 » » » » » » » » yPos = topBar -
(botbar-topbar)/2 - config.inGraphDataPaddingY; | 3478 » » » » » » » » yPos = topBar +
(botBar-topBar)/2 - config.inGraphDataPaddingY; |
3473 } else if (config.inGrap
hDataYPosition == 3) { | 3479 } else if (config.inGrap
hDataYPosition == 3) { |
3474 yPos = topBar -
config.inGraphDataPaddingY; | 3480 yPos = topBar -
config.inGraphDataPaddingY; |
3475 } | 3481 } |
3476 if(yPos>msr.topNotUsable
Size) { | 3482 if(yPos>msr.topNotUsable
Size) { |
3477 ctx.translate(xP
os, yPos); | 3483 ctx.translate(xP
os, yPos); |
3478 ctx.rotate(confi
g.inGraphDataRotate * (Math.PI / 180)); | 3484 ctx.rotate(confi
g.inGraphDataRotate * (Math.PI / 180)); |
3479 ctx.fillTextMult
iLine(dispString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); | 3485 ctx.fillTextMult
iLine(dispString, 0, 0, ctx.textBaseline, config.inGraphDataFontSize); |
3480 } | 3486 } |
3481 ctx.restore(); | 3487 ctx.restore(); |
3482 if (1*data.datasets[i].d
ata[j]<0) { | 3488 if (1*data.datasets[i].d
ata[j]<0) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3545 ctx.save(); | 3551 ctx.save(); |
3546 ctx.textAlign = "right"; | 3552 ctx.textAlign = "right"; |
3547 } else { | 3553 } else { |
3548 ctx.textAlign = "center"; | 3554 ctx.textAlign = "center"; |
3549 } | 3555 } |
3550 ctx.fillStyle = config.scaleFontColor; | 3556 ctx.fillStyle = config.scaleFontColor; |
3551 if (config.xAxisBottom) { | 3557 if (config.xAxisBottom) { |
3552 for (var i = 0; i < data.labels.length;
i++) { | 3558 for (var i = 0; i < data.labels.length;
i++) { |
3553 ctx.save(); | 3559 ctx.save(); |
3554 if (msr.rotateLabels > 0) { | 3560 if (msr.rotateLabels > 0) { |
3555 » » » » » » » ctx.translate(yAxisPosX
+ i * valueHop + (barWidth / 2) - msr.highestXLabel / 2, msr.xLabelPos); | 3561 » » » » » » » ctx.translate(yAxisPosX
+ config.barValueSpacing + i * valueHop + (barWidth / 2) - msr.highestXLabel / 2
, msr.xLabelPos); |
3556 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); | 3562 ctx.rotate(-(msr.rotateL
abels * (Math.PI / 180))); |
3557 ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), 0, 0, ctx.textBaseline, conf
ig.scaleFontSize); | 3563 ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), 0, 0, ctx.textBaseline, conf
ig.scaleFontSize); |
3558 } else { | 3564 } else { |
3559 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), yAxisPosX + i * valueHop + (
barWidth / 2), msr.xLabelPos, ctx.textBaseline, config.scaleFontSize); | 3565 » » » » » » » ctx.fillTextMultiLine(fm
tChartJS(config, data.labels[i], config.fmtXLabel), yAxisPosX + config.barValueS
pacing + i * valueHop + (barWidth / 2), msr.xLabelPos, ctx.textBaseline, config.
scaleFontSize); |
3560 } | 3566 } |
3561 ctx.restore(); | 3567 ctx.restore(); |
3562 } | 3568 } |
3563 } | 3569 } |
3564 } | 3570 } |
3565 //Y axis | 3571 //Y axis |
3566 ctx.textAlign = "right"; | 3572 ctx.textAlign = "right"; |
3567 ctx.textBaseline = "middle"; | 3573 ctx.textBaseline = "middle"; |
3568 for (var j = ((config.showYAxisMin) ? -1 : 0); j < calcu
latedScale.steps; j++) { | 3574 for (var j = ((config.showYAxisMin) ? -1 : 0); j < calcu
latedScale.steps; j++) { |
3569 if (config.scaleShowLabels) { | 3575 if (config.scaleShowLabels) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3768 } | 3774 } |
3769 } | 3775 } |
3770 for (var i = 0; i < data.datasets.length; i++) { | 3776 for (var i = 0; i < data.datasets.length; i++) { |
3771 if (animPc >= 1) { | 3777 if (animPc >= 1) { |
3772 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | 3778 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); |
3773 else lgtxt = ""; | 3779 else lgtxt = ""; |
3774 } | 3780 } |
3775 for (var j = 0; j < data.datasets[i].data.length
; j++) { | 3781 for (var j = 0; j < data.datasets[i].data.length
; j++) { |
3776 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; | 3782 var currentAnimPc = animationCorrection(
animPc, data, config, i, j, 1).animVal; |
3777 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; | 3783 if (currentAnimPc > 1) currentAnimPc = c
urrentAnimPc - 1; |
3778 » » » » » if (i == 0) { | 3784 » » » » » if (typeof tempp[j] == "undefined") { |
3779 tempp[j]=0; | 3785 tempp[j]=0; |
3780 tempn[j]=0; | 3786 tempn[j]=0; |
3781 zeroY= HorizontalCalculateOffse
t(0 , calculatedScale, scaleHop); | 3787 zeroY= HorizontalCalculateOffse
t(0 , calculatedScale, scaleHop); |
3782 } | 3788 } |
3783 var barOffset = xAxisPosY + config.barVa
lueSpacing - scaleHop * (j + 1); | 3789 var barOffset = xAxisPosY + config.barVa
lueSpacing - scaleHop * (j + 1); |
3784 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined') && 1*data.datasets[i].data[j] != 0 ) { | 3790 if (!(typeof(data.datasets[i].data[j]) =
= 'undefined') && 1*data.datasets[i].data[j] != 0 ) { |
3785 if (1*data.datasets[i].data[j]<0
) { | 3791 if (1*data.datasets[i].data[j]<0
) { |
3786 var botval=tempp[j]; | 3792 var botval=tempp[j]; |
3787 var topval=tempp[j]+1*da
ta.datasets[i].data[j] ; | 3793 var topval=tempp[j]+1*da
ta.datasets[i].data[j] ; |
3788 } else { | 3794 } else { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3839 } | 3845 } |
3840 if (1*data.datasets[i].data[j]<0
) { | 3846 if (1*data.datasets[i].data[j]<0
) { |
3841 tempp[j]=tempp[j]+1*data
.datasets[i].data[j] ; | 3847 tempp[j]=tempp[j]+1*data
.datasets[i].data[j] ; |
3842 } else { | 3848 } else { |
3843 tempn[j]=tempn[j]+1*data
.datasets[i].data[j] ; | 3849 tempn[j]=tempn[j]+1*data
.datasets[i].data[j] ; |
3844 } | 3850 } |
3845 } | 3851 } |
3846 } | 3852 } |
3847 } | 3853 } |
3848 if (animPc >= 1 && config.inGraphDataShow) { | 3854 if (animPc >= 1 && config.inGraphDataShow) { |
| 3855 |
| 3856 var tempp = new Array(data.datasets.length); |
| 3857 var tempn = new Array(data.datasets.length); |
| 3858 |
3849 var yPos = 0, | 3859 var yPos = 0, |
3850 xPos = 0; | 3860 xPos = 0; |
3851 for (var i = 0; i < data.datasets.length; i++) { | 3861 for (var i = 0; i < data.datasets.length; i++) { |
3852 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 3862 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
3853 cumvalue[j] = 0; | 3863 cumvalue[j] = 0; |
3854 } | 3864 } |
3855 } | 3865 } |
3856 for (var i = 0; i < data.datasets.length; i++) { | 3866 for (var i = 0; i < data.datasets.length; i++) { |
3857 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); | 3867 if (typeof(data.datasets[i].title) == "s
tring") lgtxt = data.datasets[i].title.trim(); |
3858 else lgtxt = ""; | 3868 else lgtxt = ""; |
3859 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { | 3869 for (var j = 0; j < data.datasets[i].dat
a.length; j++) { |
3860 » » » » » » if (i == 0) { | 3870 » » » » » » if (typeof tempp[j] == "undefine
d") { |
3861 tempp[j]=0; | 3871 tempp[j]=0; |
3862 tempn[j]=0; | 3872 tempn[j]=0; |
3863 zeroY= HorizontalCalcul
ateOffset(0 , calculatedScale, scaleHop); | 3873 zeroY= HorizontalCalcul
ateOffset(0 , calculatedScale, scaleHop); |
3864 } | 3874 } |
3865 if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { | 3875 if (!(typeof(data.datasets[i].da
ta[j]) == 'undefined')) { |
3866 if (1*data.datasets[i].d
ata[j]<0) { | 3876 if (1*data.datasets[i].d
ata[j]<0) { |
3867 var botval=tempp
[j]; | 3877 var botval=tempp
[j]; |
3868 var topval=tempp
[j]+1*data.datasets[i].data[j] ; | 3878 var topval=tempp
[j]+1*data.datasets[i].data[j] ; |
3869 } else { | 3879 } else { |
3870 var botval=tempn
[j]; | 3880 var botval=tempn
[j]; |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5553 else leftNotUsableSize = borderWidth + config.sp
aceLeft + yAxisLabelWidth + widestXLabel + config.yAxisSpaceLeft + config.yAxisS
paceRight; | 5563 else leftNotUsableSize = borderWidth + config.sp
aceLeft + yAxisLabelWidth + widestXLabel + config.yAxisSpaceLeft + config.yAxisS
paceRight; |
5554 } | 5564 } |
5555 if (config.yAxisRight) { | 5565 if (config.yAxisRight) { |
5556 if (reverseAxis == false) rightNotUsableSize = b
orderWidth + config.spaceRight + yAxisLabelWidth + widestYLabel2 + config.yAxisS
paceLeft + config.yAxisSpaceRight; | 5566 if (reverseAxis == false) rightNotUsableSize = b
orderWidth + config.spaceRight + yAxisLabelWidth + widestYLabel2 + config.yAxisS
paceLeft + config.yAxisSpaceRight; |
5557 else rightNotUsableSize = borderWidth + config.s
paceRight + yAxisLabelWidth + widestXLabel + config.yAxisSpaceLeft + config.yAxi
sSpaceRight; | 5567 else rightNotUsableSize = borderWidth + config.s
paceRight + yAxisLabelWidth + widestXLabel + config.yAxisSpaceLeft + config.yAxi
sSpaceRight; |
5558 } | 5568 } |
5559 } | 5569 } |
5560 availableWidth = width - leftNotUsableSize - rightNotUsableSize; | 5570 availableWidth = width - leftNotUsableSize - rightNotUsableSize; |
5561 // Title | 5571 // Title |
5562 if (config.graphTitle.trim() != "") { | 5572 if (config.graphTitle.trim() != "") { |
5563 » » » graphTitleHeight = (config.graphTitleFontSize + config.g
raphTitleSpaceBefore + config.graphTitleSpaceAfter); | 5573 » » » graphTitleHeight = (config.graphTitleFontSize * (config.
graphTitle.split("\n").length || 1) + config.graphTitleSpaceBefore + config.grap
hTitleSpaceAfter); |
5564 graphTitlePosY = borderWidth + config.spaceTop + graphTi
tleHeight - config.graphTitleSpaceAfter; | 5574 graphTitlePosY = borderWidth + config.spaceTop + graphTi
tleHeight - config.graphTitleSpaceAfter; |
5565 } | 5575 } |
5566 // subTitle | 5576 // subTitle |
5567 if (config.graphSubTitle.trim() != "") { | 5577 if (config.graphSubTitle.trim() != "") { |
5568 » » » graphSubTitleHeight = (config.graphSubTitleFontSize + co
nfig.graphSubTitleSpaceBefore + config.graphSubTitleSpaceAfter); | 5578 » » » graphSubTitleHeight = (config.graphSubTitleFontSize * (c
onfig.graphSubTitle.split("\n").length || 1) + config.graphSubTitleSpaceBefore +
config.graphSubTitleSpaceAfter); |
5569 graphSubTitlePosY = borderWidth + config.spaceTop + grap
hTitleHeight + graphSubTitleHeight - config.graphSubTitleSpaceAfter; | 5579 graphSubTitlePosY = borderWidth + config.spaceTop + grap
hTitleHeight + graphSubTitleHeight - config.graphSubTitleSpaceAfter; |
5570 } | 5580 } |
5571 // yAxisUnit | 5581 // yAxisUnit |
5572 if (drawAxis) { | 5582 if (drawAxis) { |
5573 if (config.yAxisUnit.trim() != "") { | 5583 if (config.yAxisUnit.trim() != "") { |
5574 yAxisUnitHeight = (config.yAxisUnitFontSize + co
nfig.yAxisUnitSpaceBefore + config.yAxisUnitSpaceAfter); | 5584 yAxisUnitHeight = (config.yAxisUnitFontSize + co
nfig.yAxisUnitSpaceBefore + config.yAxisUnitSpaceAfter); |
5575 yAxisUnitPosY = borderWidth + config.spaceTop +
graphTitleHeight + graphSubTitleHeight + yAxisUnitHeight - config.yAxisUnitSpace
After; | 5585 yAxisUnitPosY = borderWidth + config.spaceTop +
graphTitleHeight + graphSubTitleHeight + yAxisUnitHeight - config.yAxisUnitSpace
After; |
5576 } | 5586 } |
5577 } | 5587 } |
5578 topNotUsableSize = borderWidth + config.spaceTop + graphTitleHei
ght + graphSubTitleHeight + yAxisUnitHeight + config.graphSpaceBefore; | 5588 topNotUsableSize = borderWidth + config.spaceTop + graphTitleHei
ght + graphSubTitleHeight + yAxisUnitHeight + config.graphSpaceBefore; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5844 } | 5854 } |
5845 // Draw Graph Title | 5855 // Draw Graph Title |
5846 if (graphTitleHeight > 0) { | 5856 if (graphTitleHeight > 0) { |
5847 ctx.save(); | 5857 ctx.save(); |
5848 ctx.beginPath(); | 5858 ctx.beginPath(); |
5849 ctx.font = config.graphTitleFontStyle + " " + co
nfig.graphTitleFontSize + "px " + config.graphTitleFontFamily; | 5859 ctx.font = config.graphTitleFontStyle + " " + co
nfig.graphTitleFontSize + "px " + config.graphTitleFontFamily; |
5850 ctx.fillStyle = config.graphTitleFontColor; | 5860 ctx.fillStyle = config.graphTitleFontColor; |
5851 ctx.textAlign = "center"; | 5861 ctx.textAlign = "center"; |
5852 ctx.textBaseline = "bottom"; | 5862 ctx.textBaseline = "bottom"; |
5853 ctx.translate(config.spaceLeft + (width - config
.spaceLeft - config.spaceRight) / 2, graphTitlePosY); | 5863 ctx.translate(config.spaceLeft + (width - config
.spaceLeft - config.spaceRight) / 2, graphTitlePosY); |
5854 » » » » ctx.fillText(config.graphTitle, 0, 0); | 5864 » » » » ctx.fillTextMultiLine(config.graphTitle, 0, 0, c
tx.textBaseline, config.graphTitleFontSize); |
5855 ctx.stroke(); | 5865 ctx.stroke(); |
5856 ctx.restore(); | 5866 ctx.restore(); |
5857 } | 5867 } |
5858 // Draw Graph Sub-Title | 5868 // Draw Graph Sub-Title |
5859 if (graphSubTitleHeight > 0) { | 5869 if (graphSubTitleHeight > 0) { |
5860 ctx.save(); | 5870 ctx.save(); |
5861 ctx.beginPath(); | 5871 ctx.beginPath(); |
5862 ctx.font = config.graphSubTitleFontStyle + " " +
config.graphSubTitleFontSize + "px " + config.graphSubTitleFontFamily; | 5872 ctx.font = config.graphSubTitleFontStyle + " " +
config.graphSubTitleFontSize + "px " + config.graphSubTitleFontFamily; |
5863 ctx.fillStyle = config.graphSubTitleFontColor; | 5873 ctx.fillStyle = config.graphSubTitleFontColor; |
5864 ctx.textAlign = "center"; | 5874 ctx.textAlign = "center"; |
5865 ctx.textBaseline = "bottom"; | 5875 ctx.textBaseline = "bottom"; |
5866 ctx.translate(config.spaceLeft + (width - config
.spaceLeft - config.spaceRight) / 2, graphSubTitlePosY); | 5876 ctx.translate(config.spaceLeft + (width - config
.spaceLeft - config.spaceRight) / 2, graphSubTitlePosY); |
5867 » » » » ctx.fillText(config.graphSubTitle, 0, 0); | 5877 » » » » ctx.fillTextMultiLine(config.graphSubTitle, 0, 0
, ctx.textBaseline, config.graphSubTitleFontSize); |
5868 ctx.stroke(); | 5878 ctx.stroke(); |
5869 ctx.restore(); | 5879 ctx.restore(); |
5870 } | 5880 } |
5871 // Draw Y Axis Unit | 5881 // Draw Y Axis Unit |
5872 if (yAxisUnitHeight > 0) { | 5882 if (yAxisUnitHeight > 0) { |
5873 if (config.yAxisLeft) { | 5883 if (config.yAxisLeft) { |
5874 ctx.save(); | 5884 ctx.save(); |
5875 ctx.beginPath(); | 5885 ctx.beginPath(); |
5876 ctx.font = config.yAxisUnitFontStyle + "
" + config.yAxisUnitFontSize + "px " + config.yAxisUnitFontFamily; | 5886 ctx.font = config.yAxisUnitFontStyle + "
" + config.yAxisUnitFontSize + "px " + config.yAxisUnitFontFamily; |
5877 ctx.fillStyle = config.yAxisUnitFontColo
r; | 5887 ctx.fillStyle = config.yAxisUnitFontColo
r; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5941 ctx.restore(); | 5951 ctx.restore(); |
5942 } | 5952 } |
5943 } | 5953 } |
5944 // Draw Legend | 5954 // Draw Legend |
5945 | 5955 |
5946 if (nbeltLegend > 1 || (nbeltLegend == 1 && config.showS
ingleLegend)) { | 5956 if (nbeltLegend > 1 || (nbeltLegend == 1 && config.showS
ingleLegend)) { |
5947 var legendMsr={dispLegend : true, xLegendBorderP
os : xLegendBorderPos, | 5957 var legendMsr={dispLegend : true, xLegendBorderP
os : xLegendBorderPos, |
5948 yLegendBorderPos : yLegendBorderPos,
legendBorderWidth : legendBorderWidth, legendBorderHeight : legendBorderHeight, | 5958 yLegendBorderPos : yLegendBorderPos,
legendBorderWidth : legendBorderWidth, legendBorderHeight : legendBorderHeight, |
5949 nbLegendCols: nbLegendCols, xFirstLeg
endTextPos : xFirstLegendTextPos , yFirstLegendTextPos : yFirstLegendTextPos, | 5959 nbLegendCols: nbLegendCols, xFirstLeg
endTextPos : xFirstLegendTextPos , yFirstLegendTextPos : yFirstLegendTextPos, |
5950 drawLegendOnData : drawLegendOnData,
reverseLegend : reverseLegend, legendBox : legendBox, widestLegend : widestLegen
d }; | 5960 drawLegendOnData : drawLegendOnData,
reverseLegend : reverseLegend, legendBox : legendBox, widestLegend : widestLegen
d }; |
5951 » » » » if(config.legendPosY==0 || config.legendPosY==4)
{ | 5961 » » » » if(config.legendPosY==0 || config.legendPosY==4
|| config.legendPosX==0 || config.legendPosX==4) { |
5952 drawLegend(legendMsr,data,config,ctx,typ
egraph); | 5962 drawLegend(legendMsr,data,config,ctx,typ
egraph); |
5953 var legendMsr={dispLegend : false}; | 5963 var legendMsr={dispLegend : false}; |
5954 } | 5964 } |
5955 } else { | 5965 } else { |
5956 var legendMsr={dispLegend : false }; | 5966 var legendMsr={dispLegend : false }; |
5957 } | 5967 } |
5958 // Draw FootNote | 5968 // Draw FootNote |
5959 if (config.footNote.trim() != "") { | 5969 if (config.footNote.trim() != "") { |
5960 ctx.save(); | 5970 ctx.save(); |
5961 ctx.font = config.footNoteFontStyle + " " + conf
ig.footNoteFontSize + "px " + config.footNoteFontFamily; | 5971 ctx.font = config.footNoteFontStyle + " " + conf
ig.footNoteFontSize + "px " + config.footNoteFontFamily; |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6482 ctx.textAlign = "left"; | 6492 ctx.textAlign = "left"; |
6483 ctx.textBaseline = "bottom"; | 6493 ctx.textBaseline = "bottom"; |
6484 ctx.translate(xpos + config.legendBlockSize + co
nfig.legendSpaceBetweenBoxAndText, ypos); | 6494 ctx.translate(xpos + config.legendBlockSize + co
nfig.legendSpaceBetweenBoxAndText, ypos); |
6485 ctx.fillText(lgtxt, 0, 0); | 6495 ctx.fillText(lgtxt, 0, 0); |
6486 ctx.stroke(); | 6496 ctx.stroke(); |
6487 ctx.restore(); | 6497 ctx.restore(); |
6488 } | 6498 } |
6489 } | 6499 } |
6490 } | 6500 } |
6491 }; | 6501 }; |
OLD | NEW |