Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: polymer_0.5.4/bower_components/chartnewjs/ChartNew.js

Issue 895523005: Added Polymer 0.5.4 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: polymer_0.5.4/bower_components/chartnewjs/ChartNew.js
diff --git a/polymer_0.5.0/bower_components/chartnewjs/ChartNew.js b/polymer_0.5.4/bower_components/chartnewjs/ChartNew.js
similarity index 98%
copy from polymer_0.5.0/bower_components/chartnewjs/ChartNew.js
copy to polymer_0.5.4/bower_components/chartnewjs/ChartNew.js
index 66980940a1d49c2816597b4c2cabb236f966f878..3f1a87d523cb436fef6f9333476747e627355dde 100644
--- a/polymer_0.5.0/bower_components/chartnewjs/ChartNew.js
+++ b/polymer_0.5.4/bower_components/chartnewjs/ChartNew.js
@@ -1,4 +1,4 @@
-/* ²
+/*
* ChartNew.js
*
* Vancoppenolle Francois - January 2014
@@ -218,7 +218,14 @@ function isNumber(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
};
-function tmplbis(str, data) {
+function tmplbis(str, data,config) {
+ newstr=str;
+ if(newstr.substr(0,config.templatesOpenTag.length)==config.templatesOpenTag)newstr="<%="+newstr.substr(config.templatesOpenTag.length,newstr.length-config.templatesOpenTag.length);
+ if(newstr.substr(newstr.length-config.templatesCloseTag.length,config.templatesCloseTag.length)==config.templatesCloseTag)newstr=newstr.substr(0,newstr.length-config.templatesCloseTag.length)+"%>";
+ return tmplter(newstr,data);
+}
+
+function tmplter(str, data) {
var mathFunctionList = ["mean", "varianz", "stddev", "cv", "median"];
var regexMath = new RegExp('<%=((?:(?:.*?)\\W)??)((?:' + mathFunctionList.join('|') + ')(?:Dif)?)\\(([0-9]*?)\\)(.*?)%>', 'g');
while (regexMath.test(str)) {
@@ -239,7 +246,7 @@ function tmplbis(str, data) {
// load the template - and be sure to cache the result.
// first check if it's can be an id
var fn = /^[A-Za-z][-A-Za-z0-9_:.]*$/.test(str) ? cachebis[str] = cachebis[str] ||
- tmplbis(document.getElementById(str).innerHTML) :
+ tmplter(document.getElementById(str).innerHTML) :
// Generate a reusable function that will serve as a template
// generator (and which will be cached).
new Function("obj",
@@ -733,7 +740,7 @@ function doMouseAction(config, ctx, event, data, action, funct) {
myStatData.graphPosY = canvas_pos.y;
onData = true;
if (action == "annotate") {
- dispString = tmplbis(setOptionValue("ANNOTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,config.annotateLabel,jsGraphAnnotate[ctx.ChartNewId][i][12],-1,{otherVal:true}), myStatData);
+ dispString = tmplbis(setOptionValue("ANNOTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,config.annotateLabel,jsGraphAnnotate[ctx.ChartNewId][i][12],-1,{otherVal:true}), myStatData,config);
annotateDIV.innerHTML = dispString;
show = true;
} else {
@@ -755,7 +762,7 @@ function doMouseAction(config, ctx, event, data, action, funct) {
myStatData.graphPosY = canvas_pos.y;
onData = true;
if (action == "annotate") {
- dispString = tmplbis(setOptionValue("ANNOTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,config.annotateLabel,jsGraphAnnotate[ctx.ChartNewId][i][1],jsGraphAnnotate[ctx.ChartNewId][i][2],{otherVal:true}), myStatData);
+ dispString = tmplbis(setOptionValue("ANNOTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,config.annotateLabel,jsGraphAnnotate[ctx.ChartNewId][i][1],jsGraphAnnotate[ctx.ChartNewId][i][2],{otherVal:true}), myStatData,config);
annotateDIV.innerHTML = dispString;
show = true;
} else {
@@ -796,7 +803,7 @@ function doMouseAction(config, ctx, event, data, action, funct) {
myStatData.graphPosY = canvas_pos.y;
onData = true;
if (action == "annotate") {
- dispString = tmplbis(setOptionValue("ANNOTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,config.annotateLabel,jsGraphAnnotate[ctx.ChartNewId][i][1],jsGraphAnnotate[ctx.ChartNewId][i][2],{otherVal:true}), myStatData);
+ dispString = tmplbis(setOptionValue("ANNOTATELABEL",ctx,data,jsGraphAnnotate[ctx.ChartNewId][i][3],undefined,config.annotateLabel,jsGraphAnnotate[ctx.ChartNewId][i][1],jsGraphAnnotate[ctx.ChartNewId][i][2],{otherVal:true}), myStatData,config);
annotateDIV.innerHTML = dispString;
show = true;
} else {
@@ -1608,14 +1615,18 @@ window.Chart = function(context) {
thousandSeparator: "",
roundNumber: "none",
roundPct: -1,
+ templatesOpenTag : "<%=",
+ templatesCloseTag : "%>",
fmtV1: "none",
fmtV2: "none",
fmtV3: "none",
fmtV4: "none",
fmtV5: "none",
fmtV6: "none",
+ fmtV6T: "none",
fmtV7: "none",
fmtV8: "none",
+ fmtV8T: "none",
fmtV9: "none",
fmtV10: "none",
fmtV11: "none",
@@ -1845,7 +1856,7 @@ window.Chart = function(context) {
} else ctx.textBaseline = setOptionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullValue : true} );
ctx.font = setOptionValue("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,-1,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ) + 'px ' + setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphDataFontFamily,i,-1,{nullValue : true} );
ctx.fillStyle = setOptionValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,-1,{nullValue : true} );
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i],config);
ctx.translate(midPosX + labelRadius * Math.cos(posAngle), midPosY - labelRadius * Math.sin(posAngle));
if (setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : true} ) == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle);
else if (setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : true} ) == "inRadiusAxisRotateLabels") {
@@ -2059,7 +2070,7 @@ window.Chart = function(context) {
if ((j * rotationDegree + 2 * Math.PI) % (2 * Math.PI) > Math.PI / 2 && (j * rotationDegree + 2 * Math.PI) % (2 * Math.PI) < 3 * Math.PI / 2) ctx.rotate(3 * Math.PI + j * rotationDegree);
else ctx.rotate(2 * Math.PI + j * rotationDegree);
} else ctx.rotate(setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : true} ) * (Math.PI / 180));
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i][j]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i][j],config);
ctx.fillTextMultiLine(dispString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ),true);
ctx.restore();
}
@@ -2328,7 +2339,7 @@ window.Chart = function(context) {
} else ctx.textBaseline = setOptionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullValue : true} );
ctx.font = setOptionValue("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,-1,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ) + 'px ' + setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphDataFontFamily,i,-1,{nullValue : true} );
ctx.fillStyle = setOptionValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,-1,{nullValue : true} );
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i],config);
ctx.translate(midPieX + labelRadius * Math.cos(posAngle), midPieY - labelRadius * Math.sin(posAngle));
if (setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : true} ) == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle);
else if (setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : true} ) == "inRadiusAxisRotateLabels") {
@@ -2359,7 +2370,7 @@ window.Chart = function(context) {
else if (setOptionValue("INGRAPHDATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{nullValue : true} ) == 2) posAngle = realCumulativeAngle - statData[i].segmentAngle / 2 + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180);
else if (setOptionValue("INGRAPHDATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{nullValue : true} ) == 3) posAngle = realCumulativeAngle - statData[i].segmentAngle + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180);
realCumulativeAngle -= statData[i].segmentAngle;
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i],config);
var textMeasurement = ctx.measureText(dispString).width;
var MaxRadiusX = Math.abs((msr.availableWidth / 2 - textMeasurement) / Math.cos(posAngle)) - setOptionValue("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadius,i,-1,{nullValue: true} ) - 5;
if (MaxRadiusX < pieRadius) pieRadius = MaxRadiusX;
@@ -2466,7 +2477,7 @@ window.Chart = function(context) {
} else ctx.textBaseline = setOptionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,-1,{nullValue : true} );
ctx.font = setOptionValue("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,-1,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,-1,{nullValue : true} ) + 'px ' + setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphDataFontFamily,i,-1,{nullValue : true} );
ctx.fillStyle = setOptionValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,-1,{nullValue : true} );
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i],config);
ctx.translate(midPieX + labelRadius * Math.cos(posAngle), midPieY - labelRadius * Math.sin(posAngle));
if (setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : true} ) == "inRadiusAxis") ctx.rotate(2 * Math.PI - posAngle);
else if (setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,-1,{nullValue : true} ) == "inRadiusAxisRotateLabels") {
@@ -2497,7 +2508,7 @@ window.Chart = function(context) {
else if (setOptionValue("INGRAPHDATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{nullValue : true} ) == 2) posAngle = realCumulativeAngle - statData[i].segmentAngle / 2 + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180);
else if (setOptionValue("INGRAPHDATAANGLEPOSITION",ctx,data,statData,undefined,config.inGraphDataAnglePosition,i,-1,{nullValue : true} ) == 3) posAngle = realCumulativeAngle - statData[i].segmentAngle + setOptionValue("INGRAPHDATAPADDINANGLE",ctx,data,statData,undefined,config.inGraphDataPaddingAngle,i,-1,{nullValue: true }) * (Math.PI / 180);
realCumulativeAngle -= statData[i].segmentAngle;
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,-1,{nullValue : true} ), statData[i],config);
var textMeasurement = ctx.measureText(dispString).width;
var MaxRadiusX = Math.abs((msr.availableWidth / 2 - textMeasurement) / Math.cos(posAngle)) - setOptionValue("INGRAPHDATAPADDINGRADIUS",ctx,data,statData,undefined,config.inGraphDataPaddingRadius,i,-1,{nullValue: true} ) - 5;
if (MaxRadiusX < doughnutRadius) doughnutRadius = MaxRadiusX;
@@ -2905,7 +2916,7 @@ window.Chart = function(context) {
if (labelTemplateString) {
calculatedScale.labels.push(tmpl(labelTemplateString, {
value: fmtChartJS(config, 1 * ((scaleStartValue + (scaleStepWidth * i)).toFixed(getDecimalPlaces(scaleStepWidth))), config.fmtYLabel)
- }));
+ },config));
}
}
msr = setMeasures(data, config, ctx, height, width, calculatedScale.labels, null, true, false, true, true, true, "StackedBar");
@@ -2988,7 +2999,7 @@ window.Chart = function(context) {
ctx.textBaseline = setOptionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,j,{nullValue : true} );
ctx.font = setOptionValue("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,j,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ) + 'px ' + setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphDataFontFamily,i,j,{nullValue : true} );
ctx.fillStyle = setOptionValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,j,{nullValue : true} );
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ), statData[i][j]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ), statData[i][j],config);
ctx.beginPath();
ctx.beginPath();
yPos = 0;
@@ -3243,7 +3254,7 @@ window.Chart = function(context) {
if (labelTemplateString) {
calculatedScale.labels.push(tmpl(labelTemplateString, {
value: fmtChartJS(config, 1 * ((scaleStartValue + (scaleStepWidth * i)).toFixed(getDecimalPlaces(scaleStepWidth))), config.fmtYLabel)
- }));
+ },config));
}
}
msr = setMeasures(data, config, ctx, height, width, calculatedScale.labels, null, true, true, true, true, true, "HorizontalStackedBar");
@@ -3331,7 +3342,7 @@ window.Chart = function(context) {
ctx.textBaseline = setOptionValue("INGRAPHDATAVALIGN",ctx,data,statData,undefined,config.inGraphDataVAlign,i,j,{nullValue : true} );
ctx.font = setOptionValue("INGRAPHDATAFONTSTYLE",ctx,data,statData,undefined,config.inGraphDataFontStyle,i,j,{nullValue : true} ) + ' ' + setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ) + 'px ' + setOptionValue("INGRAPHDATAFONTFAMILY",ctx,data,statData,undefined,config.inGraphDataFontFamily,i,j,{nullValue : true} );
ctx.fillStyle = setOptionValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,j,{nullValue : true} );
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ),statData[i][j]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ),statData[i][j],config);
ctx.beginPath();
yPos = 0;
xPos = 0;
@@ -3349,12 +3360,12 @@ window.Chart = function(context) {
} else if (setOptionValue("INGRAPHDATAYPOSITION",ctx,data,statData,undefined,config.inGraphDataYPosition,i,j,{nullValue : true} ) == 3) {
yPos = statData[i][j].yPosTop - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefined,config.inGraphDataPaddingY,i,j,{nullValue : true} );
}
- if(xPos<=msr.availableWidth+msr.leftNotUsableSize) {
+// if(xPos<=msr.availableWidth+msr.leftNotUsableSize) {
ctx.translate(xPos, yPos);
ctx.rotate(setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,j,{nullValue : true} ) * (Math.PI / 180));
ctx.fillTextMultiLine(dispString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),true);
ctx.restore();
- }
+// }
}
}
}
@@ -3725,7 +3736,7 @@ window.Chart = function(context) {
yPos = statData[i][j].yPosTop - setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefined,config.inGraphDataPaddingY,i,j,{nullValue : true} );
}
ctx.translate(xPos, yPos);
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ), statData[i][j]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ), statData[i][j],config);
ctx.rotate(setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,j,{nullValue : true} ) * (Math.PI / 180));
ctx.fillTextMultiLine(dispString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),true);
ctx.restore();
@@ -4074,7 +4085,7 @@ window.Chart = function(context) {
xPos = statData[i][j].xPosRight + setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefined,config.inGraphDataPaddingX,i,j,{nullValue : true} );
}
ctx.translate(xPos, yPos);
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ), statData[i][j]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ), statData[i][j],config);
ctx.rotate(setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,j,{nullValue : true} ) * (Math.PI / 180));
ctx.fillTextMultiLine(dispString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),true);
ctx.restore();
@@ -4453,14 +4464,14 @@ window.Chart = function(context) {
for (var i = 0; i < numberOfSteps + 1; i++) {
labels.push(tmpl(labelTemplateString, {
value: fmtChartJS(config, 1 * ((graphMin + (stepValue * i)).toFixed(getDecimalPlaces(stepValue))), fmtYLabel)
- }));
+ },config));
}
} else { // logarithmic scale 10,100,1000,...
var value = graphMin;
for (var i = 0; i < numberOfSteps + 1; i++) {
labels.push(tmpl(labelTemplateString, {
value: fmtChartJS(config, 1 * value.toFixed(getDecimalPlaces(value)), fmtYLabel)
- }));
+ },config));
value *= 10;
}
}
@@ -4520,13 +4531,20 @@ window.Chart = function(context) {
};
//Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/
var cache = {};
+
+ function tmpl(str, data,config) {
+ newstr=str;
+ if(newstr.substr(0,config.templatesOpenTag.length)==config.templatesOpenTag)newstr="<%="+newstr.substr(config.templatesOpenTag.length,newstr.length-config.templatesOpenTag.length);
+ if(newstr.substr(newstr.length-config.templatesCloseTag.length,config.templatesCloseTag.length)==config.templatesCloseTag)newstr=newstr.substr(0,newstr.length-config.templatesCloseTag.length)+"%>";
+ return tmplpart2(newstr,data);
+ }
- function tmpl(str, data) {
+ function tmplpart2(str, data) {
// Figure out if we're getting a template, or if we need to
// load the template - and be sure to cache the result.
var fn = !/\W/.test(str) ?
cache[str] = cache[str] ||
- tmpl(document.getElementById(str).innerHTML) :
+ tmplpart2(document.getElementById(str).innerHTML) :
// Generate a reusable function that will serve as a template
// generator (and which will be cached).
new Function("obj",
@@ -5458,7 +5476,7 @@ window.Chart = function(context) {
ctx.fillStyle = setOptionValue("INGRAPHDATAFONTCOLOR",ctx,data,statData,undefined,config.inGraphDataFontColor,i,j,{nullValue : true} );
var paddingTextX = setOptionValue("INGRAPHDATAPADDINGX",ctx,data,statData,undefined,config.inGraphDataPaddingX,i,j,{nullValue : true} ),
paddingTextY = setOptionValue("INGRAPHDATAPADDINGY",ctx,data,statData,undefined,config.inGraphDataPaddingY,i,j,{nullValue : true} );
- var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ), statData[i][j]);
+ var dispString = tmplbis(setOptionValue("INGRAPHDATATMPL",ctx,data,statData,undefined,config.inGraphDataTmpl,i,j,{nullValue : true} ), statData[i][j],config);
ctx.translate(statData[i][j].xPos + paddingTextX, statData[i][j].yAxisPos - currentAnimPc.mainVal * statData[i][j].yPosOffset - paddingTextY);
ctx.rotate(setOptionValue("INGRAPHDATAROTATE",ctx,data,statData,undefined,config.inGraphDataRotate,i,j,{nullValue : true} ) * (Math.PI / 180));
ctx.fillTextMultiLine(dispString, 0, 0, ctx.textBaseline, setOptionValue("INGRAPHDATAFONTSIZE",ctx,data,statData,undefined,config.inGraphDataFontSize,i,j,{nullValue : true} ),true);
@@ -6024,6 +6042,7 @@ switch(ctx.tpchart) {
var lastNotMissingj=[];
prevpos[0]=[];
prevpos[1]=[];
+ var grandtotal=0;
for (var i = 0; i < data.datasets.length; i++) {
// BUG when all data are missing !
if (typeof data.datasets[i].xPos != "undefined" && tpdraw(ctx,data.datasets[i])=="Line") {
@@ -6054,6 +6073,7 @@ switch(ctx.tpchart) {
mnvalue[1][j]=Number.MAX_VALUE;
}
if (!(typeof data.datasets[i].data[j] == 'undefined')) {
+ grandtotal += 1 * data.datasets[i].data[j];
if(firstNotMissingi[i]==-1)firstNotMissingi[i]=j;
lastNotMissingi[i]=j;
if(firstNotMissingj[j]==-1)firstNotMissingj[j]=i;
@@ -6083,14 +6103,14 @@ switch(ctx.tpchart) {
if (lgtxt2 == "" && !(typeof(data.labels[j]) == "undefined")) lgtxt2 = data.labels[j];
if (typeof lgtxt2 == "string") lgtxt2 = lgtxt2.trim();
- if (!(typeof(data.datasets[i].data[j]) == 'undefined')) {
+// if (!(typeof(data.datasets[i].data[j]) == 'undefined') && data.datasets[i].data[j] != 0) {
+ if (!(typeof(data.datasets[i].data[j]) == 'undefined') ) {
cumvalue[axis][j]+=1*data.datasets[i].data[j];
switch(tpdraw(ctx,data.datasets[i])) {
case "Bar" :
case "StackedBar" :
case "HorizontalBar" :
case "HorizontalStackedBar" :
-
result[i][j]= {
config: config,
v1: fmtChartJS(config, lgtxt, config.fmtV1),
@@ -6099,6 +6119,7 @@ switch(ctx.tpchart) {
v4: fmtChartJS(config, cumvalue[axis][j], config.fmtV4),
v5: fmtChartJS(config, totvalue[axis][j], config.fmtV5),
v6: roundToWithThousands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[axis][j], config.fmtV6), config.roundPct),
+ v6T: roundToWithThousands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / grandtotal, config.fmtV6T), config.roundPct),
v11: fmtChartJS(config, i, config.fmtV11),
v12: fmtChartJS(config, j, config.fmtV12),
lgtxt: lgtxt,
@@ -6107,10 +6128,12 @@ switch(ctx.tpchart) {
cumvalue: cumvalue[axis][j],
totvalue: totvalue[axis][j],
pctvalue: 100 * data.datasets[i].data[j] / totvalue[axis][j],
+ pctvalueT: 100 * data.datasets[i].data[j] / grandtotal,
maxvalue : mxvalue[axis][j],
minvalue : mnvalue[axis][j],
lmaxvalue : lmaxvalue[axis][i],
lminvalue : lminvalue[axis][i],
+ grandtotal : grandtotal,
firstNotMissing : firstNotMissingj[j],
lastNotMissing : lastNotMissingj[j],
prevNotMissing : prevnotemptyj,
@@ -6120,6 +6143,7 @@ switch(ctx.tpchart) {
i: i,
data: data
};
+ if(1 * data.datasets[i].data[j]==0 && (tpdraw(ctx,data.datasets[i])=="HorizontalStackedBar" || tpdraw(ctx,data.datasets[i])=="StackedBar"))result[i][j].v3="";
break;
case "Line" :
case "Radar" :
@@ -6129,9 +6153,10 @@ switch(ctx.tpchart) {
v2: fmtChartJS(config, lgtxt2, config.fmtV2),
v3: fmtChartJS(config, 1 * data.datasets[i].data[j], config.fmtV3),
v5: fmtChartJS(config, 1 * data.datasets[i].data[j], config.fmtV5),
- v6: fmtChartJS(config, mxvalue[axis][j], config.fmtV7),
- v7: fmtChartJS(config, totvalue[axis][j], config.fmtV6),
+ v6: fmtChartJS(config, mxvalue[axis][j], config.fmtV6),
+ v7: fmtChartJS(config, totvalue[axis][j], config.fmtV7),
v8: roundToWithThousands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / totvalue[axis][j], config.fmtV8), config.roundPct),
+ v8T: roundToWithThousands(config, fmtChartJS(config, 100 * data.datasets[i].data[j] / grandtotal, config.fmtV8T), config.roundPct),
v11: fmtChartJS(config, i, config.fmtV11),
v12: fmtChartJS(config, j, config.fmtV12),
lgtxt: lgtxt,
@@ -6139,6 +6164,7 @@ switch(ctx.tpchart) {
datavalue: 1 * data.datasets[i].data[j],
diffnext: 1 * data.datasets[i].data[j],
pctvalue: 100 * data.datasets[i].data[j] / totvalue[axis][j],
+ pctvalueT: 100 * data.datasets[i].data[j] / grandtotal,
totvalue : totvalue[axis][j],
cumvalue: cumvalue[axis][j],
maxvalue : mxvalue[axis][j],
@@ -6146,6 +6172,7 @@ switch(ctx.tpchart) {
lmaxvalue : lmaxvalue[axis][i],
lminvalue : lminvalue[axis][i],
lminvalue : lminvalue[axis][i],
+ grandtotal : grandtotal,
firstNotMissing : firstNotMissingi[i],
lastNotMissing : lastNotMissingi[i],
prevNotMissing : prevnotemptyj,
@@ -6188,6 +6215,7 @@ switch(ctx.tpchart) {
lastNotMissing : lastNotMissingj[j],
prevNotMissing : prevnotemptyj,
prevMissing : prevemptyj,
+ grandtotal : grandtotal,
};
break;
case "Line" :
@@ -6200,6 +6228,7 @@ switch(ctx.tpchart) {
lastNotMissing : lastNotMissingi[i],
prevNotMissing : prevnotemptyj,
prevMissing : prevemptyj,
+ grandtotal : grandtotal,
};
break;
}
@@ -6420,7 +6449,8 @@ switch(ctx.tpchart) {
tempp[j]=0;
tempn[j]=0;
}
- if ((typeof(data.datasets[i].data[j]) == 'undefined') || 1*data.datasets[i].data[j] == 0 ) continue;
+ if (typeof(data.datasets[i].data[j]) == 'undefined') continue;
+// if ((typeof(data.datasets[i].data[j]) == 'undefined') || 1*data.datasets[i].data[j] == 0 ) continue;
statData[i][j].xPosLeft= othervars.yAxisPosX + config.barValueSpacing + othervars.valueHop * j;
if (1*data.datasets[i].data[j]<0) {
@@ -6550,11 +6580,17 @@ function setOptionValue(reference,ctx,data,statData,optionvar,defaultvalue,posi,
if(typeof optionvar == "undefined") {
if(typeof defaultvalue=="function") return defaultvalue(reference,ctx,data,statData,posi,posj,othervars);
- else if(typeof defaultvalue == "object") return defaultvalue[Math.min(defaultvalue.length-1,Math.max(0,posi))];
+ else if(typeof defaultvalue == "object") {
+ if(posj==-1)return defaultvalue[Math.min(defaultvalue.length-1,Math.max(0,posi))];
+ else return defaultvalue[Math.min(defaultvalue.length-1,Math.max(0,posj))];
+ }
else return defaultvalue;
}
if(typeof optionvar=="function") return optionvar(reference,ctx,data,statData,posi,posj,othervars);
- else if(typeof optionvar == "object") return optionvar[Math.min(optionvar.length-1,Math.max(0,posi))];
+ else if(typeof optionvar == "object") {
+ if (posj==-1)return optionvar[Math.min(optionvar.length-1,Math.max(0,posi))];
+ else return optionvar[Math.min(optionvar.length-1,Math.max(0,posj))];
+ }
else return optionvar;
};
« no previous file with comments | « polymer_0.5.4/bower_components/chartnewjs/Add-ins/stats.js ('k') | polymer_0.5.4/bower_components/chartnewjs/LICENSE » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698