{value:(c.scaleStartValue+c.scaleStepWidth*k).toFixed(A(c.scaleStepWidth))}))}else j=D(k,g,h,d,l,e);m=f/j.steps;x(c,function(){var d=2*Math.PI/a.datasets[0].data.length;b.save();b.translate(q/2,u/2);if(c.angleShowLineOut){b.strokeStyle=c.angleLineColor;b.lineWidth=c.angleLineWidth;for(var e=0;e<a.datasets[0].data.length;e++)b.rotate(d),b.beginPath(),b.moveTo(0,0),b.lineTo(0,-f),b.stroke()}for(e=0;e<j.steps;e++){b.beginPath();if(c.scaleShowLine){b.strokeStyle=c.scaleLineColor;b.lineWidth=c.scaleLineWidth;
b.moveTo(0,-m*(e+1));for(var g=0;g<a.datasets[0].data.length;g++)b.rotate(d),b.lineTo(0,-m*(e+1));b.closePath();b.stroke()}c.scaleShowLabels&&(b.textAlign="center",b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily,b.textBaseline="middle",c.scaleShowLabelBackdrop&&(g=b.measureText(j.labels[e]).width,b.fillStyle=c.scaleBackdropColor,b.beginPath(),b.rect(Math.round(-g/2-c.scaleBackdropPaddingX),Math.round(-m*(e+1)-0.5*c.scaleFontSize-c.scaleBackdropPaddingY),Math.round(g+2*c.scaleBackdropPaddingX),
Math.round(c.scaleFontSize+2*c.scaleBackdropPaddingY)),b.fill()),b.fillStyle=c.scaleFontColor,b.fillText(j.labels[e],0,-m*(e+1)))}for(e=0;e<a.labels.length;e++){b.font=c.pointLabelFontStyle+" "+c.pointLabelFontSize+"px "+c.pointLabelFontFamily;b.fillStyle=c.pointLabelFontColor;var g=Math.sin(d*e)*(f+c.pointLabelFontSize),h=Math.cos(d*e)*(f+c.pointLabelFontSize);b.textAlign=d*e==Math.PI||0==d*e?"center":d*e>Math.PI?"right":"left";b.textBaseline="middle";b.fillText(a.labels[e],g,-h)}b.restore()},function(d){var e=
-2*Math.PI/a.datasets[0].data.length;b.save();b.translate(q/2,u/2);b.rotate(e);for(var f=0;f<a.datasets.length;f++){b.beginPath();b.moveTo(0,d*-1*v(a.datasets[f].data[0],j,m));for(var g=1;g<a.datasets[f].data.length;g++)b.rotate(e),b.lineTo(0,d*-1*v(a.datasets[f].data[g],j,m));b.closePath();b.fillStyle=a.datasets[f].fillColor;b.strokeStyle=a.datasets[f].strokeColor;b.lineWidth=c.datasetStrokeWidth;b.fill();b.stroke();if(c.pointDot){b.fillStyle=a.datasets[f].pointColor;b.strokeStyle=a.datasets[f].pointStrokeColor;
-b.lineWidth=c.pointDotStrokeWidth;for(g=0;g<a.datasets[f].data.length;g++)b.rotate(e),b.beginPath(),b.arc(0,d*-1*v(a.datasets[f].data[g],j,m),c.pointDotRadius,2*Math.PI,!1),b.fill(),b.stroke()}}b.restore()},b)},I=function(a,c,b){for(var d=0,l=Math.min.apply(Math,[u/2,q/2])-5,g=0;g<a.length;g++)d+=a[g].value;x(c,null,function(g){var f=-Math.PI/2,m=1,j=1;c.animation&&(c.animateScale&&(m=g),c.animateRotate&&(j=g));for(g=0;g<a.length;g++){var e=j*a[g].value/d*2*Math.PI;b.beginPath();b.arc(q/2,u/2,m*l,
-f,f+e);b.lineTo(q/2,u/2);b.closePath();b.fillStyle=a[g].color;b.fill();c.segmentShowStroke&&(b.lineWidth=c.segmentStrokeWidth,b.strokeStyle=c.segmentStrokeColor,b.stroke());f+=e}},b)},J=function(a,c,b){for(var d=0,l=Math.min.apply(Math,[u/2,q/2])-5,g=l*(c.percentageInnerCutout/100),h=0;h<a.length;h++)d+=a[h].value;x(c,null,function(f){var h=-Math.PI/2,j=1,e=1;c.animation&&(c.animateScale&&(j=f),c.animateRotate&&(e=f));for(f=0;f<a.length;f++){var k=e*a[f].value/d*2*Math.PI;b.beginPath();b.arc(q/2,
-u/2,j*l,h,h+k,!1);b.arc(q/2,u/2,j*g,h+k,h,!0);b.closePath();b.fillStyle=a[f].color;b.fill();c.segmentShowStroke&&(b.lineWidth=c.segmentStrokeWidth,b.strokeStyle=c.segmentStrokeColor,b.stroke());h+=k}},b)},K=function(a,c,b){var d,l,g,h,f,m,j,e,k,t,r,n,p,s=0;f=u;b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;t=1;for(e=0;e<a.labels.length;e++)d=b.measureText(a.labels[e]).width,t=d>t?d:t;q/a.labels.length<t?(s=45,q/a.labels.length<Math.cos(s)*t?(s=90,f-=t):f-=Math.sin(s)*t):f-=c.scaleFontSize;
-e=c.scaleFontSize;f=f-5-e;d=Number.MIN_VALUE;l=Number.MAX_VALUE;for(g=0;g<a.datasets.length;g++)for(h=0;h<a.datasets[g].data.length;h++)a.datasets[g].data[h]>d&&(d=a.datasets[g].data[h]),a.datasets[g].data[h]<l&&(l=a.datasets[g].data[h]);g=Math.floor(f/(0.66*e));h=Math.floor(0.5*(f/e));e=c.scaleShowLabels?c.scaleLabel:"";if(c.scaleOverride){j={steps:c.scaleSteps,stepValue:c.scaleStepWidth,graphMin:c.scaleStartValue,labels:[]};for(d=0;d<j.steps;d++)e&&j.labels.push(y(e,{value:(c.scaleStartValue+c.scaleStepWidth*
-d).toFixed(A(c.scaleStepWidth))}))}else j=D(f,g,h,d,l,e);m=Math.floor(f/j.steps);e=1;if(c.scaleShowLabels){b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;for(d=0;d<j.labels.length;d++)l=b.measureText(j.labels[d]).width,e=l>e?l:e;e+=10}r=q-e-t;k=Math.floor(r/(a.labels.length-1));n=q-t/2-r;p=f+c.scaleFontSize/2;x(c,function(){b.lineWidth=c.scaleLineWidth;b.strokeStyle=c.scaleLineColor;b.beginPath();b.moveTo(q-t/2+5,p);b.lineTo(q-t/2-r-5,p);b.stroke();0<s?(b.save(),b.textAlign="right"):
-b.textAlign="center";b.fillStyle=c.scaleFontColor;for(var d=0;d<a.labels.length;d++)b.save(),0<s?(b.translate(n+d*k,p+c.scaleFontSize),b.rotate(-(s*(Math.PI/180))),b.fillText(a.labels[d],0,0),b.restore()):b.fillText(a.labels[d],n+d*k,p+c.scaleFontSize+3),b.beginPath(),b.moveTo(n+d*k,p+3),c.scaleShowGridLines&&0<d?(b.lineWidth=c.scaleGridLineWidth,b.strokeStyle=c.scaleGridLineColor,b.lineTo(n+d*k,5)):b.lineTo(n+d*k,p+3),b.stroke();b.lineWidth=c.scaleLineWidth;b.strokeStyle=c.scaleLineColor;b.beginPath();
-b.moveTo(n,p+5);b.lineTo(n,5);b.stroke();b.textAlign="right";b.textBaseline="middle";for(d=0;d<j.steps;d++)b.beginPath(),b.moveTo(n-3,p-(d+1)*m),c.scaleShowGridLines?(b.lineWidth=c.scaleGridLineWidth,b.strokeStyle=c.scaleGridLineColor,b.lineTo(n+r+5,p-(d+1)*m)):b.lineTo(n-0.5,p-(d+1)*m),b.stroke(),c.scaleShowLabels&&b.fillText(j.labels[d],n-8,p-(d+1)*m)},function(d){function e(b,c){return p-d*v(a.datasets[b].data[c],j,m)}for(var f=0;f<a.datasets.length;f++){b.strokeStyle=a.datasets[f].strokeColor;
+2*Math.PI/a.datasets[0].data.length;b.save();b.translate(q/2,u/2);for(var f=0;f<a.datasets.length;f++){b.beginPath();b.moveTo(0,d*-1*v(a.datasets[f].data[0],j,m));for(var g=1;g<a.datasets[f].data.length;g++)b.rotate(e),b.lineTo(0,d*-1*v(a.datasets[f].data[g],j,m));b.closePath();b.fillStyle=a.datasets[f].fillColor;b.strokeStyle=a.datasets[f].strokeColor;b.lineWidth=c.datasetStrokeWidth;b.fill();b.stroke();if(c.pointDot){b.fillStyle=a.datasets[f].pointColor;b.strokeStyle=a.datasets[f].pointStrokeColor;
+b.lineWidth=c.pointDotStrokeWidth;for(g=0;g<a.datasets[f].data.length;g++)b.rotate(e),b.beginPath(),b.arc(0,d*-1*v(a.datasets[f].data[g],j,m),c.pointDotRadius,2*Math.PI,!1),b.fill(),b.stroke()}b.rotate(e)}b.restore()},b)},I=function(a,c,b){for(var d=0,l=Math.min.apply(Math,[u/2,q/2])-5,g=0;g<a.length;g++)d+=a[g].value;x(c,null,function(g){var f=-Math.PI/2,m=1,j=1;c.animation&&(c.animateScale&&(m=g),c.animateRotate&&(j=g));for(g=0;g<a.length;g++){var e=j*a[g].value/d*2*Math.PI;b.beginPath();b.arc(q/
+2,u/2,m*l,f,f+e);b.lineTo(q/2,u/2);b.closePath();b.fillStyle=a[g].color;b.fill();c.segmentShowStroke&&(b.lineWidth=c.segmentStrokeWidth,b.strokeStyle=c.segmentStrokeColor,b.stroke());f+=e}},b)},J=function(a,c,b){for(var d=0,l=Math.min.apply(Math,[u/2,q/2])-5,g=l*(c.percentageInnerCutout/100),h=0;h<a.length;h++)d+=a[h].value;x(c,null,function(f){var h=-Math.PI/2,j=1,e=1;c.animation&&(c.animateScale&&(j=f),c.animateRotate&&(e=f));for(f=0;f<a.length;f++){var k=e*a[f].value/d*2*Math.PI;b.beginPath();
+b.arc(q/2,u/2,j*l,h,h+k,!1);b.arc(q/2,u/2,j*g,h+k,h,!0);b.closePath();b.fillStyle=a[f].color;b.fill();c.segmentShowStroke&&(b.lineWidth=c.segmentStrokeWidth,b.strokeStyle=c.segmentStrokeColor,b.stroke());h+=k}},b)},K=function(a,c,b){var d,l,g,h,f,m,j,e,k,t,r,n,p,s=0;f=u;b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;t=1;for(e=0;e<a.labels.length;e++)d=b.measureText(a.labels[e]).width,t=d>t?d:t;q/a.labels.length<t?(s=45,q/a.labels.length<Math.cos(s)*t?(s=90,f-=t):f-=Math.sin(s)*
+t):f-=c.scaleFontSize;e=c.scaleFontSize;f=f-5-e;d=Number.MIN_VALUE;l=Number.MAX_VALUE;for(g=0;g<a.datasets.length;g++)for(h=0;h<a.datasets[g].data.length;h++)a.datasets[g].data[h]>d&&(d=a.datasets[g].data[h]),a.datasets[g].data[h]<l&&(l=a.datasets[g].data[h]);g=Math.floor(f/(0.66*e));h=Math.floor(0.5*(f/e));e=c.scaleShowLabels?c.scaleLabel:"";if(c.scaleOverride){j={steps:c.scaleSteps,stepValue:c.scaleStepWidth,graphMin:c.scaleStartValue,labels:[]};for(d=0;d<j.steps;d++)e&&j.labels.push(y(e,{value:(c.scaleStartValue+
+c.scaleStepWidth*d).toFixed(A(c.scaleStepWidth))}))}else j=D(f,g,h,d,l,e);m=Math.floor(f/j.steps);e=1;if(c.scaleShowLabels){b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;for(d=0;d<j.labels.length;d++)l=b.measureText(j.labels[d]).width,e=l>e?l:e;e+=10}r=q-e-t;k=Math.floor(r/(a.labels.length-1));n=q-t/2-r;p=f+c.scaleFontSize/2;x(c,function(){b.lineWidth=c.scaleLineWidth;b.strokeStyle=c.scaleLineColor;b.beginPath();b.moveTo(q-t/2+5,p);b.lineTo(q-t/2-r-5,p);b.stroke();0<s?(b.save(),
+b.textAlign="right"):b.textAlign="center";b.fillStyle=c.scaleFontColor;for(var d=0;d<a.labels.length;d++)b.save(),0<s?(b.translate(n+d*k,p+c.scaleFontSize),b.rotate(-(s*(Math.PI/180))),b.fillText(a.labels[d],0,0),b.restore()):b.fillText(a.labels[d],n+d*k,p+c.scaleFontSize+3),b.beginPath(),b.moveTo(n+d*k,p+3),c.scaleShowGridLines&&0<d?(b.lineWidth=c.scaleGridLineWidth,b.strokeStyle=c.scaleGridLineColor,b.lineTo(n+d*k,5)):b.lineTo(n+d*k,p+3),b.stroke();b.lineWidth=c.scaleLineWidth;b.strokeStyle=c.scaleLineColor;
+b.beginPath();b.moveTo(n,p+5);b.lineTo(n,5);b.stroke();b.textAlign="right";b.textBaseline="middle";for(d=0;d<j.steps;d++)b.beginPath(),b.moveTo(n-3,p-(d+1)*m),c.scaleShowGridLines?(b.lineWidth=c.scaleGridLineWidth,b.strokeStyle=c.scaleGridLineColor,b.lineTo(n+r+5,p-(d+1)*m)):b.lineTo(n-0.5,p-(d+1)*m),b.stroke(),c.scaleShowLabels&&b.fillText(j.labels[d],n-8,p-(d+1)*m)},function(d){function e(b,c){return p-d*v(a.datasets[b].data[c],j,m)}for(var f=0;f<a.datasets.length;f++){b.strokeStyle=a.datasets[f].strokeColor;
b.lineWidth=c.datasetStrokeWidth;b.beginPath();b.moveTo(n,p-d*v(a.datasets[f].data[0],j,m));for(var g=1;g<a.datasets[f].data.length;g++)c.bezierCurve?b.bezierCurveTo(n+k*(g-0.5),e(f,g-1),n+k*(g-0.5),e(f,g),n+k*g,e(f,g)):b.lineTo(n+k*g,e(f,g));b.stroke();c.datasetFill?(b.lineTo(n+k*(a.datasets[f].data.length-1),p),b.lineTo(n,p),b.closePath(),b.fillStyle=a.datasets[f].fillColor,b.fill()):b.closePath();if(c.pointDot){b.fillStyle=a.datasets[f].pointColor;b.strokeStyle=a.datasets[f].pointStrokeColor;b.lineWidth=
c.pointDotStrokeWidth;for(g=0;g<a.datasets[f].data.length;g++)b.beginPath(),b.arc(n+k*g,p-d*v(a.datasets[f].data[g],j,m),c.pointDotRadius,0,2*Math.PI,!0),b.fill(),b.stroke()}}},b)},L=function(a,c,b){var d,l,g,h,f,m,j,e,k,t,r,n,p,s,w=0;f=u;b.font=c.scaleFontStyle+" "+c.scaleFontSize+"px "+c.scaleFontFamily;t=1;for(e=0;e<a.labels.length;e++)d=b.measureText(a.labels[e]).width,t=d>t?d:t;q/a.labels.length<t?(w=45,q/a.labels.length<Math.cos(w)*t?(w=90,f-=t):f-=Math.sin(w)*t):f-=c.scaleFontSize;e=c.scaleFontSize;
f=f-5-e;d=Number.MIN_VALUE;l=Number.MAX_VALUE;for(g=0;g<a.datasets.length;g++)for(h=0;h<a.datasets[g].data.length;h++)a.datasets[g].data[h]>d&&(d=a.datasets[g].data[h]),a.datasets[g].data[h]<l&&(l=a.datasets[g].data[h]);g=Math.floor(f/(0.66*e));h=Math.floor(0.5*(f/e));e=c.scaleShowLabels?c.scaleLabel:"";if(c.scaleOverride){j={steps:c.scaleSteps,stepValue:c.scaleStepWidth,graphMin:c.scaleStartValue,labels:[]};for(d=0;d<j.steps;d++)e&&j.labels.push(y(e,{value:(c.scaleStartValue+c.scaleStepWidth*d).toFixed(A(c.scaleStepWidth))}))}else j=
+/*!
+ * Chart.js
+ * http://chartjs.org/
+ *
+ * Copyright 2013 Nick Downie
+ * Released under the MIT license
+ * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
+ */
+
//Define the global Chart Variable as a class.
var Chart = function(context){
};
this.Doughnut = function(data,options){
+
chart.Doughnut.defaults = {
segmentShowStroke : true,
segmentStrokeColor : "#fff",
ctx.save();
//translate to the centre of the canvas.
ctx.translate(width/2,height/2);
- ctx.rotate(rotationDegree);
+
//We accept multiple data sets for radar charts, so show loop through each set
for (var i=0; i<data.datasets.length; i++){
ctx.beginPath();
}
}
+ ctx.rotate(rotationDegree);
}
ctx.restore();
}
//Declare global functions to be called within this namespace here.
+
+
// shim layer with setTimeout fallback
var requestAnimFrame = (function(){
return window.requestAnimationFrame ||
valueRange = maxValue - minValue;
rangeOrderOfMagnitude = calculateOrderOfMagnitude(valueRange);
- //var graphRange = (Math.ceil(rangeMultipland) * Math.pow(10, rangeOrderOfMagnitude));
- graphMin = (Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude));
+
+ graphMin = Math.floor(minValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude);
- graphMax = (Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude));
+ graphMax = Math.ceil(maxValue / (1 * Math.pow(10, rangeOrderOfMagnitude))) * Math.pow(10, rangeOrderOfMagnitude);
graphRange = graphMax - graphMin;
stepValue = Math.pow(10, rangeOrderOfMagnitude);
+
numberOfSteps = Math.round(graphRange / stepValue);
-
+ //Compare number of steps to the max and min for that size graph, and add in half steps if need be.
while(numberOfSteps < minSteps || numberOfSteps > maxSteps) {
if (numberOfSteps < minSteps){
stepValue /= 2;
}
};
- //Compare number of steps to the max and min for that size graph, and add in half steps if need be.
+
//Create an array of all the labels by interpolating the string.
var labels = [];
+
if(labelTemplateString){
//Fix floating point errors by setting to fixed the on the same decimal as the stepValue.
for (var i=1; i<numberOfSteps+1; i++){
}
}
+
function mergeChartConfig(defaults,userDefined){
var returnObj = {};
for (var attrname in defaults) { returnObj[attrname] = defaults[attrname]; }
for (var attrname in userDefined) { returnObj[attrname] = userDefined[attrname]; }
return returnObj;
}
+
//Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/
var cache = {};