language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | chartjs | Chart.js | 7a231313668f3b3dfe949dabd2c8da69f9088c55.json | Add datasetLabel to elements for tooltip templates | src/Chart.Radar.js | @@ -121,6 +121,7 @@
datasetObject.points.push(new this.PointClass({
value : dataPoint,
label : data.labels[index],
+ datasetLabel: dataset.label,
x: (this.options.animation) ? this.scale.xCenter : pointPosition.x,
y: (this.options.animation) ? this.scale.yCenter : pointPosition.y,
strokeColor : dataset.pointStrokeColor, | true |
Other | chartjs | Chart.js | d7632efe65dde5deb2a19c01aa3d01d91458ef56.json | Prevent spare datasets from breaking MultiTooltips | src/Chart.Core.js | @@ -873,7 +873,9 @@
yMin;
helpers.each(this.datasets, function(dataset){
dataCollection = dataset.points || dataset.bars || dataset.segments;
- Elements.push(dataCollection[dataIndex]);
+ if (dataCollection[dataIndex]){
+ Elements.push(dataCollection[dataIndex]);
+ }
});
helpers.each(Elements, function(element) { | false |
Other | chartjs | Chart.js | 477e09f1d406b71f0c3f8990da7d0037c427125f.json | Add support for CommonJS module definition | Chart.js | @@ -1873,6 +1873,8 @@
define(function(){
return Chart;
});
+ } else if (typeof module === 'object' && module.exports) {
+ module.exports = Chart;
}
root.Chart = Chart; | true |
Other | chartjs | Chart.js | 477e09f1d406b71f0c3f8990da7d0037c427125f.json | Add support for CommonJS module definition | Chart.min.js | @@ -6,5 +6,5 @@
* Released under the MIT license
* https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
*/
-(function(){"use strict";var t=this,i=t.Chart,e=function(t){this.canvas=t.canvas,this.ctx=t;this.width=t.canvas.width,this.height=t.canvas.height;return this.aspectRatio=this.width/this.height,s.retinaScale(this),this};e.defaults={global:{animation:!0,animationSteps:60,animationEasing:"easeOutQuart",showScale:!0,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleIntegersOnly:!0,scaleBeginAtZero:!1,scaleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",responsive:!1,showTooltips:!0,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipFillColor:"rgba(0,0,0,0.8)",tooltipFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipFontSize:14,tooltipFontStyle:"normal",tooltipFontColor:"#fff",tooltipTitleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipTitleFontSize:14,tooltipTitleFontStyle:"bold",tooltipTitleFontColor:"#fff",tooltipYPadding:6,tooltipXPadding:6,tooltipCaretSize:8,tooltipCornerRadius:6,tooltipXOffset:10,tooltipTemplate:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTooltipTemplate:"<%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},e.types={};var s=e.helpers={},n=s.each=function(t,i,e){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n<t.length;n++)i.apply(e,[t[n],n].concat(s))}else for(var o in t)i.apply(e,[t[o],o].concat(s))},o=s.clone=function(t){var i={};return n(t,function(e,s){t.hasOwnProperty(s)&&(i[s]=e)}),i},a=s.extend=function(t){return n(Array.prototype.slice.call(arguments,1),function(i){n(i,function(e,s){i.hasOwnProperty(s)&&(t[s]=e)})}),t},h=s.merge=function(){var t=Array.prototype.slice.call(arguments,0);return t.unshift({}),a.apply(null,t)},l=s.indexOf=function(t,i){if(Array.prototype.indexOf)return t.indexOf(i);for(var e=0;e<t.length;e++)if(t[e]===i)return e;return-1},r=s.inherits=function(t){var i=this,e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return i.apply(this,arguments)},s=function(){this.constructor=e};return s.prototype=i.prototype,e.prototype=new s,e.extend=r,t&&a(e.prototype,t),e.__super__=i.prototype,e},c=s.noop=function(){},u=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=s.amd="function"==typeof t.define&&t.define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},m=s.min=function(t){return Math.min.apply(Math,t)},v=(s.cap=function(t,i,e){if(f(i)){if(t>i)return i}else if(f(e)&&e>t)return e;return t},s.getDecimalPlaces=function(t){return t%1!==0&&f(t)?t.toString().split(".")[1].length:0}),S=s.radians=function(t){return t*(Math.PI/180)},x=(s.getAngleFromPoint=function(t,i){var e=i.x-t.x,s=i.y-t.y,n=Math.sqrt(e*e+s*s),o=2*Math.PI+Math.atan2(s,e);return 0>e&&0>s&&(o+=2*Math.PI),{angle:o,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),C=(s.splineCurve=function(t,i,e,s){var n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=s*n/(n+o),h=s*o/(n+o);return{inner:{x:i.x-a*(e.x-t.x),y:i.y-a*(e.y-t.y)},outer:{x:i.x+h*(e.x-t.x),y:i.y+h*(e.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),y=(s.calculateScaleRange=function(t,i,e,s,n){var o=2,a=Math.floor(i/(1.5*e)),h=o>=a,l=g(t),r=m(t);l===r&&(l+=.5,r>=.5&&!s?r-=.5:l+=.5);for(var c=Math.abs(l-r),u=C(c),d=Math.ceil(l/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(r/(1*Math.pow(10,u)))*Math.pow(10,u),f=d-p,v=Math.pow(10,u),S=Math.round(f/v);(S>a||a>2*S)&&!h;)if(S>a)v*=2,S=Math.round(f/v),S%1!==0&&(h=!0);else if(n&&u>=0){if(v/2%1!==0)break;v/=2,S=Math.round(f/v)}else v/=2,S=Math.round(f/v);return h&&(S=o,v=f/S),{steps:S,stepValue:v,min:p,max:p+S*v}},s.template=function(t,i){function e(t,i){var e=/\W/.test(t)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+t.replace(/[\r\t\n]/g," ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):s[t]=s[t];return i?e(i):e}var s={};return e(t,i)}),b=(s.generateLabels=function(t,i,e,s){var o=new Array(i);return labelTemplateString&&n(o,function(i,n){o[n]=y(t,{value:e+s*(n+1)})}),o},s.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),-(s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)))},easeOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),s*Math.pow(2,-10*t)*Math.sin(2*(1*t-i)*Math.PI/e)+1)},easeInOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:2==(t/=.5)?1:(e||(e=.3*1.5),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),1>t?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)*.5+1)},easeInBack:function(t){var i=1.70158;return 1*(t/=1)*t*((i+1)*t-i)},easeOutBack:function(t){var i=1.70158;return 1*((t=t/1-1)*t*((i+1)*t+i)+1)},easeInOutBack:function(t){var i=1.70158;return(t/=.5)<1?.5*t*t*(((i*=1.525)+1)*t-i):.5*((t-=2)*t*(((i*=1.525)+1)*t+i)+2)},easeInBounce:function(t){return 1-b.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375)},easeInOutBounce:function(t){return.5>t?.5*b.easeInBounce(2*t):.5*b.easeOutBounce(2*t-1)+.5}}),w=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),P=(s.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),s.animationLoop=function(t,i,e,s,n,o){var a=0,h=b[e]||b.linear,l=function(){a++;var e=a/i,r=h(e);t.call(o,r,e,a),s.call(o,r,e),i>a?o.animationFrame=w(l):n.apply(o)};w(l)},s.getRelativePosition=function(t){var i,e,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,o=n.getBoundingClientRect();return s.touches?(i=s.touches[0].clientX-o.left,e=s.touches[0].clientY-o.top):(i=s.clientX-o.left,e=s.clientY-o.top),{x:i,y:e}},s.addEvent=function(t,i,e){t.addEventListener?t.addEventListener(i,e):t.attachEvent?t.attachEvent("on"+i,e):t["on"+i]=e}),L=s.removeEvent=function(t,i,e){t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent?t.detachEvent("on"+i,e):t["on"+i]=c},k=(s.bindEvents=function(t,i,e){t.events||(t.events={}),n(i,function(i){t.events[i]=function(){e.apply(t,arguments)},P(t.chart.canvas,i,t.events[i])})},s.unbindEvents=function(t,i){n(i,function(i,e){L(t.chart.canvas,e,i)})}),F=s.getMaximumSize=function(t){var i=t.parentNode;return i.clientWidth},R=s.retinaScale=function(t){var i=t.ctx,e=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(i.canvas.style.width=e+"px",i.canvas.style.height=s+"px",i.canvas.height=s*window.devicePixelRatio,i.canvas.width=e*window.devicePixelRatio,i.scale(window.devicePixelRatio,window.devicePixelRatio))},A=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},T=s.fontString=function(t,i,e){return i+" "+t+"px "+e},M=s.longestText=function(t,i,e){t.font=i;var s=0;return n(e,function(i){var e=t.measureText(i).width;s=e>s?e:s}),s},W=s.drawRoundedRectangle=function(t,i,e,s,n,o){t.beginPath(),t.moveTo(i+o,e),t.lineTo(i+s-o,e),t.quadraticCurveTo(i+s,e,i+s,e+o),t.lineTo(i+s,e+n-o),t.quadraticCurveTo(i+s,e+n,i+s-o,e+n),t.lineTo(i+o,e+n),t.quadraticCurveTo(i,e+n,i,e+n-o),t.lineTo(i,e+o),t.quadraticCurveTo(i,e,i+o,e),t.closePath()};e.instances={},e.Type=function(t,i,s){this.options=i,this.chart=s,this.id=u(),e.instances[this.id]=this,i.responsive&&this.resize(),this.initialize.call(this,t)},a(e.Type.prototype,{initialize:function(){return this},clear:function(){return A(this.chart),this},stop:function(){return s.cancelAnimFrame.call(t,this.animationFrame),this},resize:function(t){this.stop();var i=this.chart.canvas,e=F(this.chart.canvas),s=e/this.chart.aspectRatio;return i.width=this.chart.width=e,i.height=this.chart.height=s,R(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t){return t&&this.reflow(),this.options.animation&&!t?s.animationLoop(this.draw,this.options.animationSteps,this.options.animationEasing,this.options.onAnimationProgress,this.options.onAnimationComplete,this):(this.draw(),this.options.onAnimationComplete.call(this)),this},generateLegend:function(){return y(this.options.legendTemplate,this)},destroy:function(){this.clear(),k(this,this.events),delete e.instances[this.id]},showTooltip:function(t,i){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var o=function(t){var i=!1;return t.length!==this.activeElements.length?i=!0:(n(t,function(t,e){t!==this.activeElements[e]&&(i=!0)},this),i)}.call(this,t);if(o||i){if(this.activeElements=t,this.draw(),t.length>0)if(this.datasets&&this.datasets.length>1){for(var a,h,r=this.datasets.length-1;r>=0&&(a=this.datasets[r].points||this.datasets[r].bars||this.datasets[r].segments,h=l(a,t[0]),-1===h);r--);var c=[],u=[],d=function(){var t,i,e,n,o,a=[],l=[],r=[];return s.each(this.datasets,function(i){t=i.points||i.bars||i.segments,a.push(t[h])}),s.each(a,function(t){l.push(t.x),r.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._saved.fillColor||t.fillColor,stroke:t._saved.strokeColor||t.strokeColor})},this),o=m(r),e=g(r),n=m(l),i=g(l),{x:n>this.chart.width/2?n:i,y:(o+e)/2}}.call(this,h);new e.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,titleTextColor:this.options.tooltipTitleFontColor,titleFontFamily:this.options.tooltipTitleFontFamily,titleFontStyle:this.options.tooltipTitleFontStyle,titleFontSize:this.options.tooltipTitleFontSize,cornerRadius:this.options.tooltipCornerRadius,labels:c,legendColors:u,legendColorBackground:this.options.multiTooltipKeyBackground,title:t[0].label,chart:this.chart,ctx:this.chart.ctx}).draw()}else n(t,function(t){var i=t.tooltipPosition();new e.Tooltip({x:Math.round(i.x),y:Math.round(i.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,caretHeight:this.options.tooltipCaretSize,cornerRadius:this.options.tooltipCornerRadius,text:y(this.options.tooltipTemplate,t),chart:this.chart}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),e.Type.extend=function(t){var i=this,s=function(){return i.apply(this,arguments)};if(s.prototype=o(i.prototype),a(s.prototype,t),s.extend=e.Type.extend,t.name||i.prototype.name){var n=t.name||i.prototype.name,l=e.defaults[i.prototype.name]?o(e.defaults[i.prototype.name]):{};e.defaults[n]=a(l,t.defaults),e.types[n]=s,e.prototype[n]=function(t,i){var o=h(e.defaults.global,e.defaults[n],i||{});return new s(t,o,this)}}else d("Name not provided for this chart, so it hasn't been registered");return i},e.Element=function(t){a(this,t),this.initialize.apply(this,arguments),this.save()},a(e.Element.prototype,{initialize:function(){},restore:function(t){return t?n(t,function(t){this[t]=this._saved[t]},this):a(this,this._saved),this},save:function(){return this._saved=o(this),delete this._saved._saved,this},update:function(t){return n(t,function(t,i){this._saved[i]=this[i],this[i]=t},this),this},transition:function(t,i){return n(t,function(t,e){this[e]=(t-this._saved[e])*i+this._saved[e]},this),this},tooltipPosition:function(){return{x:this.x,y:this.y}}}),e.Element.extend=r,e.Point=e.Element.extend({display:!0,inRange:function(t,i){var e=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(i-this.y,2)<Math.pow(e,2)},draw:function(){if(this.display){var t=this.ctx;t.beginPath(),t.arc(this.x,this.y,this.radius,0,2*Math.PI),t.closePath(),t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.fillStyle=this.fillColor,t.fill(),t.stroke()}}}),e.Arc=e.Element.extend({inRange:function(t,i){var e=s.getAngleFromPoint(this,{x:t,y:i}),n=e.angle>=this.startAngle&&e.angle<=this.endAngle,o=e.distance>=this.innerRadius&&e.distance<=this.outerRadius;return n&&o},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,i=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*i,y:this.y+Math.sin(t)*i}},draw:function(t){var i=this.ctx;i.beginPath(),i.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),i.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),i.closePath(),i.strokeStyle=this.strokeColor,i.lineWidth=this.strokeWidth,i.fillStyle=this.fillColor,i.fill(),i.lineJoin="bevel",this.showStroke&&i.stroke()}}),e.Rectangle=e.Element.extend({draw:function(){var t=this.ctx,i=this.width/2,e=this.x-i,s=this.x+i,n=this.base-(this.base-this.y),o=this.strokeWidth/2;this.showStroke&&(e+=o,s-=o,n+=o),t.beginPath(),t.fillStyle=this.fillColor,t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.moveTo(e,this.base),t.lineTo(e,n),t.lineTo(s,n),t.lineTo(s,this.base),t.fill(),this.showStroke&&t.stroke()},height:function(){return this.base-this.y},inRange:function(t,i){return t>=this.x-this.width/2&&t<=this.x+this.width/2&&i>=this.y&&i<=this.base}}),e.Tooltip=e.Element.extend({draw:function(){var t=this.chart.ctx;t.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var i=2,e=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+i;this.x+e/2>this.chart.width?this.xAlign="left":this.x-e/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var o=this.x-e/2,a=this.y-n;switch(t.fillStyle=this.fillColor,this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-i),t.lineTo(this.x+this.caretHeight,this.y-(i+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(i+this.caretHeight)),t.closePath(),t.fill();break;case"below":a=this.y+i+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+i),t.lineTo(this.x+this.caretHeight,this.y+i+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+i+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":o=this.x-e+(this.cornerRadius+this.caretHeight);break;case"right":o=this.x-(this.cornerRadius+this.caretHeight)}W(t,o,a,e,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,o+e/2,a+s/2)}}),e.MultiTooltip=e.Element.extend({initialize:function(){this.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=T(this.titleFontSize,this.titleFontStyle,this.titleFontFamily),this.height=this.labels.length*this.fontSize+(this.labels.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize,this.ctx.font=this.titleFont;var t=this.ctx.measureText(this.title).width,i=M(this.ctx,this.font,this.labels)+this.fontSize+3,e=g([i,t]);this.width=e+2*this.xPadding;var s=this.height/2;this.y-s<0?this.y=s:this.y+s>this.chart.height&&(this.y=this.chart.height-s),this.x>this.chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset},getLineHeight:function(t){var i=this.y-this.height/2+this.yPadding,e=t-1;return 0===t?i+this.titleFontSize/2:i+(1.5*this.fontSize*e+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){W(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.fillColor,t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.titleTextColor,t.font=this.titleFont,t.fillText(this.title,this.x+this.xPadding,this.getLineHeight(0)),t.font=this.font,s.each(this.labels,function(i,e){t.fillStyle=this.textColor,t.fillText(i,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(e+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[e].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}),e.Scale=e.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(y(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?M(this.ctx,this.font,this.yLabels):0},addXLabel:function(t){this.xLabels.push(t),this.valuesCount++,this.fit()},removeXLabel:function(){this.xLabels.shift(),this.valuesCount--,this.fit()},fit:function(){this.startPoint=this.display?this.fontSize:0,this.endPoint=this.display?this.height-1.5*this.fontSize-5:this.height,this.startPoint+=this.padding,this.endPoint-=this.padding;var t,i=this.endPoint-this.startPoint;for(this.calculateYRange(i),this.buildYLabels(),this.calculateXLabelRotation();i>this.endPoint-this.startPoint;)i=this.endPoint-this.startPoint,t=this.yLabelWidth,this.calculateYRange(i),this.buildYLabels(),t<this.yLabelWidth&&this.calculateXLabelRotation()},calculateXLabelRotation:function(){this.ctx.font=this.font;var t,i,e=this.ctx.measureText(this.xLabels[0]).width,s=this.ctx.measureText(this.xLabels[this.xLabels.length-1]).width;if(this.xScalePaddingRight=s/2+3,this.xScalePaddingLeft=e/2>this.yLabelWidth+10?e/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var n,o=M(this.ctx,this.font,this.xLabels);this.xLabelWidth=o;for(var a=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>a&&0===this.xLabelRotation||this.xLabelWidth>a&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(S(this.xLabelRotation)),t=n*e,i=n*s,t+this.fontSize/2>this.yLabelWidth+8&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*o;this.xLabelRotation>0&&(this.endPoint-=Math.sin(S(this.xLabelRotation))*o+3)}else this.xLabelWidth=0,this.xScalePaddingRight=this.padding,this.xScalePaddingLeft=this.padding},calculateYRange:c,drawingArea:function(){return this.startPoint-this.endPoint},calculateY:function(t){var i=this.drawingArea()/(this.min-this.max);return this.endPoint-i*(t-this.min)},calculateX:function(t){var i=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),e=i/(this.valuesCount-(this.offsetGridLines?0:1)),s=e*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=e/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,i=(this.endPoint-this.startPoint)/this.steps,e=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,o){var a=this.endPoint-i*o,h=Math.round(a);t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,e-10,a),t.beginPath(),o>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),h+=s.aliasPixel(t.lineWidth),t.moveTo(e,h),t.lineTo(this.width,h),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(e-5,h),t.lineTo(e,h),t.stroke(),t.closePath()},this),n(this.xLabels,function(i,e){var s=this.calculateX(e)+x(this.lineWidth),n=this.calculateX(e-(this.offsetGridLines?.5:0))+x(this.lineWidth),o=this.xLabelRotation>0;t.beginPath(),e>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),t.moveTo(n,this.endPoint),t.lineTo(n,this.startPoint-3),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(n,this.endPoint),t.lineTo(n,this.endPoint+5),t.stroke(),t.closePath(),t.save(),t.translate(s,o?this.endPoint+12:this.endPoint+8),t.rotate(-1*S(this.xLabelRotation)),t.font=this.font,t.textAlign=o?"right":"center",t.textBaseline=o?"middle":"top",t.fillText(i,0,0),t.restore()},this))}}),e.RadialScale=e.Element.extend({initialize:function(){this.size=m([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var i=this.drawingArea/(this.max-this.min);return(t-this.min)*i},update:function(){this.lineArc?this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(y(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,i,e,s,n,o,a,h,l,r,c,u,d=m([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=T(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),i=0;i<this.valuesCount;i++)t=this.getPointPosition(i,d),e=this.ctx.measureText(y(this.templateString,{value:this.labels[i]})).width+5,0===i||i===this.valuesCount/2?(s=e/2,t.x+s>p&&(p=t.x+s,n=i),t.x-s<g&&(g=t.x-s,a=i)):i<this.valuesCount/2?t.x+e>p&&(p=t.x+e,n=i):i>this.valuesCount/2&&t.x-e<g&&(g=t.x-e,a=i);l=g,r=Math.ceil(p-this.width),o=this.getIndexAngle(n),h=this.getIndexAngle(a),c=r/Math.sin(o+Math.PI/2),u=l/Math.sin(h+Math.PI/2),c=f(c)?c:0,u=f(u)?u:0,this.drawingArea=d-(u+c)/2,this.setCenterPoint(u,c)},setCenterPoint:function(t,i){var e=this.width-i-this.drawingArea,s=t+this.drawingArea;this.xCenter=(s+e)/2,this.yCenter=this.height/2},getIndexAngle:function(t){var i=2*Math.PI/this.valuesCount;return t*i-Math.PI/2},getPointPosition:function(t,i){var e=this.getIndexAngle(t);return{x:Math.cos(e)*i+this.xCenter,y:Math.sin(e)*i+this.yCenter}},draw:function(){if(this.display){var t=this.ctx;if(n(this.yLabels,function(i,e){if(e>0){var s,n=e*(this.drawingArea/this.steps),o=this.yCenter-n;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var a=0;a<this.valuesCount;a++)s=this.getPointPosition(a,this.calculateCenterOffset(this.min+e*this.stepValue)),0===a?t.moveTo(s.x,s.y):t.lineTo(s.x,s.y);t.closePath(),t.stroke()}if(this.showLabels){if(t.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.showLabelBackdrop){var h=t.measureText(i).width;t.fillStyle=this.backdropColor,t.fillRect(this.xCenter-h/2-this.backdropPaddingX,o-this.fontSize/2-this.backdropPaddingY,h+2*this.backdropPaddingX,this.fontSize+2*this.backdropPaddingY)}t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.fontColor,t.fillText(i,this.xCenter,o)}}},this),!this.lineArc){t.lineWidth=this.angleLineWidth,t.strokeStyle=this.angleLineColor;for(var i=this.valuesCount-1;i>=0;i--){if(this.angleLineWidth>0){var e=this.getPointPosition(i,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(e.x,e.y),t.stroke(),t.closePath()}var s=this.getPointPosition(i,this.calculateCenterOffset(this.max)+5);t.font=T(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var o=this.labels.length,a=this.labels.length/2,h=a/2,l=h>i||i>o-h,r=i===h||i===o-h;t.textAlign=0===i?"center":i===a?"center":a>i?"left":"right",t.textBaseline=r?"middle":l?"bottom":"top",t.fillText(this.labels[i],s.x,s.y)}}}}}),s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(e.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p&&define(function(){return e}),t.Chart=e,e.noConflict=function(){return t.Chart=i,e}}).call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Bar",defaults:s,initialize:function(t){var s=this.options;this.ScaleClass=i.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,i,e){var n=this.calculateBaseWidth(),o=this.calculateX(e)-n/2,a=this.calculateBarWidth(t);return o+a*i+i*s.barDatasetSpacing+a/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var i=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return i/t}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getBarsAtEvent(t):[];this.eachBars(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),this.BarClass=i.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,bars:[]};this.datasets.push(s),e.each(i.data,function(n,o){e.isNumber(n)&&s.bars.push(new this.BarClass({value:n,label:t.labels[o],strokeColor:i.strokeColor,fillColor:i.fillColor,highlightFill:i.highlightFill||i.fillColor,highlightStroke:i.highlightStroke||i.strokeColor}))},this)},this),this.buildScale(t.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(t,i,s){e.extend(t,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,s,i),y:this.scale.endPoint}),t.save()},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachBars(function(t){t.save()}),this.render()},eachBars:function(t){e.each(this.datasets,function(i,s){e.each(i.bars,t,this,s)},this)},getBarsAtEvent:function(t){for(var i,s=[],n=e.getRelativePosition(t),o=function(t){s.push(t.bars[i])},a=0;a<this.datasets.length;a++)for(i=0;i<this.datasets[a].bars.length;i++)if(this.datasets[a].bars[i].inRange(n.x,n.y))return e.each(this.datasets,o),s;return s},buildScale:function(t){var i=this,s=function(){var t=[];return i.eachBars(function(i){t.push(i.value)}),t},n={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(s(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.barShowStroke?this.options.barStrokeWidth:0,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(n,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new this.ScaleClass(n)},addData:function(t,i){e.each(t,function(t,s){e.isNumber(t)&&this.datasets[s].bars.push(new this.BarClass({value:t,label:i,x:this.scale.calculateBarX(this.datasets.length,s,this.scale.valuesCount+1),y:this.scale.endPoint,width:this.scale.calculateBarWidth(this.datasets.length),base:this.scale.endPoint,strokeColor:this.datasets[s].strokeColor,fillColor:this.datasets[s].fillColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.bars.shift()},this),this.update()},reflow:function(){e.extend(this.BarClass.prototype,{y:this.scale.endPoint,base:this.scale.endPoint});var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();this.chart.ctx;this.scale.draw(i),e.each(this.datasets,function(t,s){e.each(t.bars,function(t,e){t.base=this.scale.endPoint,t.transition({x:this.scale.calculateBarX(this.datasets.length,s,e),y:this.scale.calculateY(t.value),width:this.scale.calculateBarWidth(this.datasets.length)},i).draw()},this)},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,percentageInnerCutout:50,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.segments=[],this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=i.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];
+(function(){"use strict";var t=this,i=t.Chart,e=function(t){this.canvas=t.canvas,this.ctx=t;this.width=t.canvas.width,this.height=t.canvas.height;return this.aspectRatio=this.width/this.height,s.retinaScale(this),this};e.defaults={global:{animation:!0,animationSteps:60,animationEasing:"easeOutQuart",showScale:!0,scaleOverride:!1,scaleSteps:null,scaleStepWidth:null,scaleStartValue:null,scaleLineColor:"rgba(0,0,0,.1)",scaleLineWidth:1,scaleShowLabels:!0,scaleLabel:"<%=value%>",scaleIntegersOnly:!0,scaleBeginAtZero:!1,scaleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",scaleFontSize:12,scaleFontStyle:"normal",scaleFontColor:"#666",responsive:!1,showTooltips:!0,tooltipEvents:["mousemove","touchstart","touchmove","mouseout"],tooltipFillColor:"rgba(0,0,0,0.8)",tooltipFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipFontSize:14,tooltipFontStyle:"normal",tooltipFontColor:"#fff",tooltipTitleFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",tooltipTitleFontSize:14,tooltipTitleFontStyle:"bold",tooltipTitleFontColor:"#fff",tooltipYPadding:6,tooltipXPadding:6,tooltipCaretSize:8,tooltipCornerRadius:6,tooltipXOffset:10,tooltipTemplate:"<%if (label){%><%=label%>: <%}%><%= value %>",multiTooltipTemplate:"<%= value %>",multiTooltipKeyBackground:"#fff",onAnimationProgress:function(){},onAnimationComplete:function(){}}},e.types={};var s=e.helpers={},n=s.each=function(t,i,e){var s=Array.prototype.slice.call(arguments,3);if(t)if(t.length===+t.length){var n;for(n=0;n<t.length;n++)i.apply(e,[t[n],n].concat(s))}else for(var o in t)i.apply(e,[t[o],o].concat(s))},o=s.clone=function(t){var i={};return n(t,function(e,s){t.hasOwnProperty(s)&&(i[s]=e)}),i},a=s.extend=function(t){return n(Array.prototype.slice.call(arguments,1),function(i){n(i,function(e,s){i.hasOwnProperty(s)&&(t[s]=e)})}),t},h=s.merge=function(){var t=Array.prototype.slice.call(arguments,0);return t.unshift({}),a.apply(null,t)},l=s.indexOf=function(t,i){if(Array.prototype.indexOf)return t.indexOf(i);for(var e=0;e<t.length;e++)if(t[e]===i)return e;return-1},r=s.inherits=function(t){var i=this,e=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return i.apply(this,arguments)},s=function(){this.constructor=e};return s.prototype=i.prototype,e.prototype=new s,e.extend=r,t&&a(e.prototype,t),e.__super__=i.prototype,e},c=s.noop=function(){},u=s.uid=function(){var t=0;return function(){return"chart-"+t++}}(),d=s.warn=function(t){window.console&&"function"==typeof window.console.warn&&console.warn(t)},p=s.amd="function"==typeof t.define&&t.define.amd,f=s.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},g=s.max=function(t){return Math.max.apply(Math,t)},m=s.min=function(t){return Math.min.apply(Math,t)},v=(s.cap=function(t,i,e){if(f(i)){if(t>i)return i}else if(f(e)&&e>t)return e;return t},s.getDecimalPlaces=function(t){return t%1!==0&&f(t)?t.toString().split(".")[1].length:0}),S=s.radians=function(t){return t*(Math.PI/180)},x=(s.getAngleFromPoint=function(t,i){var e=i.x-t.x,s=i.y-t.y,n=Math.sqrt(e*e+s*s),o=2*Math.PI+Math.atan2(s,e);return 0>e&&0>s&&(o+=2*Math.PI),{angle:o,distance:n}},s.aliasPixel=function(t){return t%2===0?0:.5}),C=(s.splineCurve=function(t,i,e,s){var n=Math.sqrt(Math.pow(i.x-t.x,2)+Math.pow(i.y-t.y,2)),o=Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2)),a=s*n/(n+o),h=s*o/(n+o);return{inner:{x:i.x-a*(e.x-t.x),y:i.y-a*(e.y-t.y)},outer:{x:i.x+h*(e.x-t.x),y:i.y+h*(e.y-t.y)}}},s.calculateOrderOfMagnitude=function(t){return Math.floor(Math.log(t)/Math.LN10)}),y=(s.calculateScaleRange=function(t,i,e,s,n){var o=2,a=Math.floor(i/(1.5*e)),h=o>=a,l=g(t),r=m(t);l===r&&(l+=.5,r>=.5&&!s?r-=.5:l+=.5);for(var c=Math.abs(l-r),u=C(c),d=Math.ceil(l/(1*Math.pow(10,u)))*Math.pow(10,u),p=s?0:Math.floor(r/(1*Math.pow(10,u)))*Math.pow(10,u),f=d-p,v=Math.pow(10,u),S=Math.round(f/v);(S>a||a>2*S)&&!h;)if(S>a)v*=2,S=Math.round(f/v),S%1!==0&&(h=!0);else if(n&&u>=0){if(v/2%1!==0)break;v/=2,S=Math.round(f/v)}else v/=2,S=Math.round(f/v);return h&&(S=o,v=f/S),{steps:S,stepValue:v,min:p,max:p+S*v}},s.template=function(t,i){function e(t,i){var e=/\W/.test(t)?new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+t.replace(/[\r\t\n]/g," ").split("<%").join(" ").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split(" ").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');"):s[t]=s[t];return i?e(i):e}var s={};return e(t,i)}),b=(s.generateLabels=function(t,i,e,s){var o=new Array(i);return labelTemplateString&&n(o,function(i,n){o[n]=y(t,{value:e+s*(n+1)})}),o},s.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),-(s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)))},easeOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:1==(t/=1)?1:(e||(e=.3),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),s*Math.pow(2,-10*t)*Math.sin(2*(1*t-i)*Math.PI/e)+1)},easeInOutElastic:function(t){var i=1.70158,e=0,s=1;return 0===t?0:2==(t/=.5)?1:(e||(e=.3*1.5),s<Math.abs(1)?(s=1,i=e/4):i=e/(2*Math.PI)*Math.asin(1/s),1>t?-.5*s*Math.pow(2,10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e):s*Math.pow(2,-10*(t-=1))*Math.sin(2*(1*t-i)*Math.PI/e)*.5+1)},easeInBack:function(t){var i=1.70158;return 1*(t/=1)*t*((i+1)*t-i)},easeOutBack:function(t){var i=1.70158;return 1*((t=t/1-1)*t*((i+1)*t+i)+1)},easeInOutBack:function(t){var i=1.70158;return(t/=.5)<1?.5*t*t*(((i*=1.525)+1)*t-i):.5*((t-=2)*t*(((i*=1.525)+1)*t+i)+2)},easeInBounce:function(t){return 1-b.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375)},easeInOutBounce:function(t){return.5>t?.5*b.easeInBounce(2*t):.5*b.easeOutBounce(2*t-1)+.5}}),w=s.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),P=(s.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),s.animationLoop=function(t,i,e,s,n,o){var a=0,h=b[e]||b.linear,l=function(){a++;var e=a/i,r=h(e);t.call(o,r,e,a),s.call(o,r,e),i>a?o.animationFrame=w(l):n.apply(o)};w(l)},s.getRelativePosition=function(t){var i,e,s=t.originalEvent||t,n=t.currentTarget||t.srcElement,o=n.getBoundingClientRect();return s.touches?(i=s.touches[0].clientX-o.left,e=s.touches[0].clientY-o.top):(i=s.clientX-o.left,e=s.clientY-o.top),{x:i,y:e}},s.addEvent=function(t,i,e){t.addEventListener?t.addEventListener(i,e):t.attachEvent?t.attachEvent("on"+i,e):t["on"+i]=e}),L=s.removeEvent=function(t,i,e){t.removeEventListener?t.removeEventListener(i,e,!1):t.detachEvent?t.detachEvent("on"+i,e):t["on"+i]=c},k=(s.bindEvents=function(t,i,e){t.events||(t.events={}),n(i,function(i){t.events[i]=function(){e.apply(t,arguments)},P(t.chart.canvas,i,t.events[i])})},s.unbindEvents=function(t,i){n(i,function(i,e){L(t.chart.canvas,e,i)})}),F=s.getMaximumSize=function(t){var i=t.parentNode;return i.clientWidth},R=s.retinaScale=function(t){var i=t.ctx,e=t.canvas.width,s=t.canvas.height;window.devicePixelRatio&&(i.canvas.style.width=e+"px",i.canvas.style.height=s+"px",i.canvas.height=s*window.devicePixelRatio,i.canvas.width=e*window.devicePixelRatio,i.scale(window.devicePixelRatio,window.devicePixelRatio))},A=s.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},T=s.fontString=function(t,i,e){return i+" "+t+"px "+e},M=s.longestText=function(t,i,e){t.font=i;var s=0;return n(e,function(i){var e=t.measureText(i).width;s=e>s?e:s}),s},W=s.drawRoundedRectangle=function(t,i,e,s,n,o){t.beginPath(),t.moveTo(i+o,e),t.lineTo(i+s-o,e),t.quadraticCurveTo(i+s,e,i+s,e+o),t.lineTo(i+s,e+n-o),t.quadraticCurveTo(i+s,e+n,i+s-o,e+n),t.lineTo(i+o,e+n),t.quadraticCurveTo(i,e+n,i,e+n-o),t.lineTo(i,e+o),t.quadraticCurveTo(i,e,i+o,e),t.closePath()};e.instances={},e.Type=function(t,i,s){this.options=i,this.chart=s,this.id=u(),e.instances[this.id]=this,i.responsive&&this.resize(),this.initialize.call(this,t)},a(e.Type.prototype,{initialize:function(){return this},clear:function(){return A(this.chart),this},stop:function(){return s.cancelAnimFrame.call(t,this.animationFrame),this},resize:function(t){this.stop();var i=this.chart.canvas,e=F(this.chart.canvas),s=e/this.chart.aspectRatio;return i.width=this.chart.width=e,i.height=this.chart.height=s,R(this.chart),"function"==typeof t&&t.apply(this,Array.prototype.slice.call(arguments,1)),this},reflow:c,render:function(t){return t&&this.reflow(),this.options.animation&&!t?s.animationLoop(this.draw,this.options.animationSteps,this.options.animationEasing,this.options.onAnimationProgress,this.options.onAnimationComplete,this):(this.draw(),this.options.onAnimationComplete.call(this)),this},generateLegend:function(){return y(this.options.legendTemplate,this)},destroy:function(){this.clear(),k(this,this.events),delete e.instances[this.id]},showTooltip:function(t,i){"undefined"==typeof this.activeElements&&(this.activeElements=[]);var o=function(t){var i=!1;return t.length!==this.activeElements.length?i=!0:(n(t,function(t,e){t!==this.activeElements[e]&&(i=!0)},this),i)}.call(this,t);if(o||i){if(this.activeElements=t,this.draw(),t.length>0)if(this.datasets&&this.datasets.length>1){for(var a,h,r=this.datasets.length-1;r>=0&&(a=this.datasets[r].points||this.datasets[r].bars||this.datasets[r].segments,h=l(a,t[0]),-1===h);r--);var c=[],u=[],d=function(){var t,i,e,n,o,a=[],l=[],r=[];return s.each(this.datasets,function(i){t=i.points||i.bars||i.segments,a.push(t[h])}),s.each(a,function(t){l.push(t.x),r.push(t.y),c.push(s.template(this.options.multiTooltipTemplate,t)),u.push({fill:t._saved.fillColor||t.fillColor,stroke:t._saved.strokeColor||t.strokeColor})},this),o=m(r),e=g(r),n=m(l),i=g(l),{x:n>this.chart.width/2?n:i,y:(o+e)/2}}.call(this,h);new e.MultiTooltip({x:d.x,y:d.y,xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,xOffset:this.options.tooltipXOffset,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,titleTextColor:this.options.tooltipTitleFontColor,titleFontFamily:this.options.tooltipTitleFontFamily,titleFontStyle:this.options.tooltipTitleFontStyle,titleFontSize:this.options.tooltipTitleFontSize,cornerRadius:this.options.tooltipCornerRadius,labels:c,legendColors:u,legendColorBackground:this.options.multiTooltipKeyBackground,title:t[0].label,chart:this.chart,ctx:this.chart.ctx}).draw()}else n(t,function(t){var i=t.tooltipPosition();new e.Tooltip({x:Math.round(i.x),y:Math.round(i.y),xPadding:this.options.tooltipXPadding,yPadding:this.options.tooltipYPadding,fillColor:this.options.tooltipFillColor,textColor:this.options.tooltipFontColor,fontFamily:this.options.tooltipFontFamily,fontStyle:this.options.tooltipFontStyle,fontSize:this.options.tooltipFontSize,caretHeight:this.options.tooltipCaretSize,cornerRadius:this.options.tooltipCornerRadius,text:y(this.options.tooltipTemplate,t),chart:this.chart}).draw()},this);return this}},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)}}),e.Type.extend=function(t){var i=this,s=function(){return i.apply(this,arguments)};if(s.prototype=o(i.prototype),a(s.prototype,t),s.extend=e.Type.extend,t.name||i.prototype.name){var n=t.name||i.prototype.name,l=e.defaults[i.prototype.name]?o(e.defaults[i.prototype.name]):{};e.defaults[n]=a(l,t.defaults),e.types[n]=s,e.prototype[n]=function(t,i){var o=h(e.defaults.global,e.defaults[n],i||{});return new s(t,o,this)}}else d("Name not provided for this chart, so it hasn't been registered");return i},e.Element=function(t){a(this,t),this.initialize.apply(this,arguments),this.save()},a(e.Element.prototype,{initialize:function(){},restore:function(t){return t?n(t,function(t){this[t]=this._saved[t]},this):a(this,this._saved),this},save:function(){return this._saved=o(this),delete this._saved._saved,this},update:function(t){return n(t,function(t,i){this._saved[i]=this[i],this[i]=t},this),this},transition:function(t,i){return n(t,function(t,e){this[e]=(t-this._saved[e])*i+this._saved[e]},this),this},tooltipPosition:function(){return{x:this.x,y:this.y}}}),e.Element.extend=r,e.Point=e.Element.extend({display:!0,inRange:function(t,i){var e=this.hitDetectionRadius+this.radius;return Math.pow(t-this.x,2)+Math.pow(i-this.y,2)<Math.pow(e,2)},draw:function(){if(this.display){var t=this.ctx;t.beginPath(),t.arc(this.x,this.y,this.radius,0,2*Math.PI),t.closePath(),t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.fillStyle=this.fillColor,t.fill(),t.stroke()}}}),e.Arc=e.Element.extend({inRange:function(t,i){var e=s.getAngleFromPoint(this,{x:t,y:i}),n=e.angle>=this.startAngle&&e.angle<=this.endAngle,o=e.distance>=this.innerRadius&&e.distance<=this.outerRadius;return n&&o},tooltipPosition:function(){var t=this.startAngle+(this.endAngle-this.startAngle)/2,i=(this.outerRadius-this.innerRadius)/2+this.innerRadius;return{x:this.x+Math.cos(t)*i,y:this.y+Math.sin(t)*i}},draw:function(t){var i=this.ctx;i.beginPath(),i.arc(this.x,this.y,this.outerRadius,this.startAngle,this.endAngle),i.arc(this.x,this.y,this.innerRadius,this.endAngle,this.startAngle,!0),i.closePath(),i.strokeStyle=this.strokeColor,i.lineWidth=this.strokeWidth,i.fillStyle=this.fillColor,i.fill(),i.lineJoin="bevel",this.showStroke&&i.stroke()}}),e.Rectangle=e.Element.extend({draw:function(){var t=this.ctx,i=this.width/2,e=this.x-i,s=this.x+i,n=this.base-(this.base-this.y),o=this.strokeWidth/2;this.showStroke&&(e+=o,s-=o,n+=o),t.beginPath(),t.fillStyle=this.fillColor,t.strokeStyle=this.strokeColor,t.lineWidth=this.strokeWidth,t.moveTo(e,this.base),t.lineTo(e,n),t.lineTo(s,n),t.lineTo(s,this.base),t.fill(),this.showStroke&&t.stroke()},height:function(){return this.base-this.y},inRange:function(t,i){return t>=this.x-this.width/2&&t<=this.x+this.width/2&&i>=this.y&&i<=this.base}}),e.Tooltip=e.Element.extend({draw:function(){var t=this.chart.ctx;t.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.xAlign="center",this.yAlign="above";var i=2,e=t.measureText(this.text).width+2*this.xPadding,s=this.fontSize+2*this.yPadding,n=s+this.caretHeight+i;this.x+e/2>this.chart.width?this.xAlign="left":this.x-e/2<0&&(this.xAlign="right"),this.y-n<0&&(this.yAlign="below");var o=this.x-e/2,a=this.y-n;switch(t.fillStyle=this.fillColor,this.yAlign){case"above":t.beginPath(),t.moveTo(this.x,this.y-i),t.lineTo(this.x+this.caretHeight,this.y-(i+this.caretHeight)),t.lineTo(this.x-this.caretHeight,this.y-(i+this.caretHeight)),t.closePath(),t.fill();break;case"below":a=this.y+i+this.caretHeight,t.beginPath(),t.moveTo(this.x,this.y+i),t.lineTo(this.x+this.caretHeight,this.y+i+this.caretHeight),t.lineTo(this.x-this.caretHeight,this.y+i+this.caretHeight),t.closePath(),t.fill()}switch(this.xAlign){case"left":o=this.x-e+(this.cornerRadius+this.caretHeight);break;case"right":o=this.x-(this.cornerRadius+this.caretHeight)}W(t,o,a,e,s,this.cornerRadius),t.fill(),t.fillStyle=this.textColor,t.textAlign="center",t.textBaseline="middle",t.fillText(this.text,o+e/2,a+s/2)}}),e.MultiTooltip=e.Element.extend({initialize:function(){this.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.titleFont=T(this.titleFontSize,this.titleFontStyle,this.titleFontFamily),this.height=this.labels.length*this.fontSize+(this.labels.length-1)*(this.fontSize/2)+2*this.yPadding+1.5*this.titleFontSize,this.ctx.font=this.titleFont;var t=this.ctx.measureText(this.title).width,i=M(this.ctx,this.font,this.labels)+this.fontSize+3,e=g([i,t]);this.width=e+2*this.xPadding;var s=this.height/2;this.y-s<0?this.y=s:this.y+s>this.chart.height&&(this.y=this.chart.height-s),this.x>this.chart.width/2?this.x-=this.xOffset+this.width:this.x+=this.xOffset},getLineHeight:function(t){var i=this.y-this.height/2+this.yPadding,e=t-1;return 0===t?i+this.titleFontSize/2:i+(1.5*this.fontSize*e+this.fontSize/2)+1.5*this.titleFontSize},draw:function(){W(this.ctx,this.x,this.y-this.height/2,this.width,this.height,this.cornerRadius);var t=this.ctx;t.fillStyle=this.fillColor,t.fill(),t.closePath(),t.textAlign="left",t.textBaseline="middle",t.fillStyle=this.titleTextColor,t.font=this.titleFont,t.fillText(this.title,this.x+this.xPadding,this.getLineHeight(0)),t.font=this.font,s.each(this.labels,function(i,e){t.fillStyle=this.textColor,t.fillText(i,this.x+this.xPadding+this.fontSize+3,this.getLineHeight(e+1)),t.fillStyle=this.legendColorBackground,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize),t.fillStyle=this.legendColors[e].fill,t.fillRect(this.x+this.xPadding,this.getLineHeight(e+1)-this.fontSize/2,this.fontSize,this.fontSize)},this)}}),e.Scale=e.Element.extend({initialize:function(){this.fit()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(y(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}));this.yLabelWidth=this.display&&this.showLabels?M(this.ctx,this.font,this.yLabels):0},addXLabel:function(t){this.xLabels.push(t),this.valuesCount++,this.fit()},removeXLabel:function(){this.xLabels.shift(),this.valuesCount--,this.fit()},fit:function(){this.startPoint=this.display?this.fontSize:0,this.endPoint=this.display?this.height-1.5*this.fontSize-5:this.height,this.startPoint+=this.padding,this.endPoint-=this.padding;var t,i=this.endPoint-this.startPoint;for(this.calculateYRange(i),this.buildYLabels(),this.calculateXLabelRotation();i>this.endPoint-this.startPoint;)i=this.endPoint-this.startPoint,t=this.yLabelWidth,this.calculateYRange(i),this.buildYLabels(),t<this.yLabelWidth&&this.calculateXLabelRotation()},calculateXLabelRotation:function(){this.ctx.font=this.font;var t,i,e=this.ctx.measureText(this.xLabels[0]).width,s=this.ctx.measureText(this.xLabels[this.xLabels.length-1]).width;if(this.xScalePaddingRight=s/2+3,this.xScalePaddingLeft=e/2>this.yLabelWidth+10?e/2:this.yLabelWidth+10,this.xLabelRotation=0,this.display){var n,o=M(this.ctx,this.font,this.xLabels);this.xLabelWidth=o;for(var a=Math.floor(this.calculateX(1)-this.calculateX(0))-6;this.xLabelWidth>a&&0===this.xLabelRotation||this.xLabelWidth>a&&this.xLabelRotation<=90&&this.xLabelRotation>0;)n=Math.cos(S(this.xLabelRotation)),t=n*e,i=n*s,t+this.fontSize/2>this.yLabelWidth+8&&(this.xScalePaddingLeft=t+this.fontSize/2),this.xScalePaddingRight=this.fontSize/2,this.xLabelRotation++,this.xLabelWidth=n*o;this.xLabelRotation>0&&(this.endPoint-=Math.sin(S(this.xLabelRotation))*o+3)}else this.xLabelWidth=0,this.xScalePaddingRight=this.padding,this.xScalePaddingLeft=this.padding},calculateYRange:c,drawingArea:function(){return this.startPoint-this.endPoint},calculateY:function(t){var i=this.drawingArea()/(this.min-this.max);return this.endPoint-i*(t-this.min)},calculateX:function(t){var i=(this.xLabelRotation>0,this.width-(this.xScalePaddingLeft+this.xScalePaddingRight)),e=i/(this.valuesCount-(this.offsetGridLines?0:1)),s=e*t+this.xScalePaddingLeft;return this.offsetGridLines&&(s+=e/2),Math.round(s)},update:function(t){s.extend(this,t),this.fit()},draw:function(){var t=this.ctx,i=(this.endPoint-this.startPoint)/this.steps,e=Math.round(this.xScalePaddingLeft);this.display&&(t.fillStyle=this.textColor,t.font=this.font,n(this.yLabels,function(n,o){var a=this.endPoint-i*o,h=Math.round(a);t.textAlign="right",t.textBaseline="middle",this.showLabels&&t.fillText(n,e-10,a),t.beginPath(),o>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),h+=s.aliasPixel(t.lineWidth),t.moveTo(e,h),t.lineTo(this.width,h),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(e-5,h),t.lineTo(e,h),t.stroke(),t.closePath()},this),n(this.xLabels,function(i,e){var s=this.calculateX(e)+x(this.lineWidth),n=this.calculateX(e-(this.offsetGridLines?.5:0))+x(this.lineWidth),o=this.xLabelRotation>0;t.beginPath(),e>0?(t.lineWidth=this.gridLineWidth,t.strokeStyle=this.gridLineColor):(t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor),t.moveTo(n,this.endPoint),t.lineTo(n,this.startPoint-3),t.stroke(),t.closePath(),t.lineWidth=this.lineWidth,t.strokeStyle=this.lineColor,t.beginPath(),t.moveTo(n,this.endPoint),t.lineTo(n,this.endPoint+5),t.stroke(),t.closePath(),t.save(),t.translate(s,o?this.endPoint+12:this.endPoint+8),t.rotate(-1*S(this.xLabelRotation)),t.font=this.font,t.textAlign=o?"right":"center",t.textBaseline=o?"middle":"top",t.fillText(i,0,0),t.restore()},this))}}),e.RadialScale=e.Element.extend({initialize:function(){this.size=m([this.height,this.width]),this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2},calculateCenterOffset:function(t){var i=this.drawingArea/(this.max-this.min);return(t-this.min)*i},update:function(){this.lineArc?this.drawingArea=this.display?this.size/2-(this.fontSize/2+this.backdropPaddingY):this.size/2:this.setScaleSize(),this.buildYLabels()},buildYLabels:function(){this.yLabels=[];for(var t=v(this.stepValue),i=0;i<=this.steps;i++)this.yLabels.push(y(this.templateString,{value:(this.min+i*this.stepValue).toFixed(t)}))},getCircumference:function(){return 2*Math.PI/this.valuesCount},setScaleSize:function(){var t,i,e,s,n,o,a,h,l,r,c,u,d=m([this.height/2-this.pointLabelFontSize-5,this.width/2]),p=this.width,g=0;for(this.ctx.font=T(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),i=0;i<this.valuesCount;i++)t=this.getPointPosition(i,d),e=this.ctx.measureText(y(this.templateString,{value:this.labels[i]})).width+5,0===i||i===this.valuesCount/2?(s=e/2,t.x+s>p&&(p=t.x+s,n=i),t.x-s<g&&(g=t.x-s,a=i)):i<this.valuesCount/2?t.x+e>p&&(p=t.x+e,n=i):i>this.valuesCount/2&&t.x-e<g&&(g=t.x-e,a=i);l=g,r=Math.ceil(p-this.width),o=this.getIndexAngle(n),h=this.getIndexAngle(a),c=r/Math.sin(o+Math.PI/2),u=l/Math.sin(h+Math.PI/2),c=f(c)?c:0,u=f(u)?u:0,this.drawingArea=d-(u+c)/2,this.setCenterPoint(u,c)},setCenterPoint:function(t,i){var e=this.width-i-this.drawingArea,s=t+this.drawingArea;this.xCenter=(s+e)/2,this.yCenter=this.height/2},getIndexAngle:function(t){var i=2*Math.PI/this.valuesCount;return t*i-Math.PI/2},getPointPosition:function(t,i){var e=this.getIndexAngle(t);return{x:Math.cos(e)*i+this.xCenter,y:Math.sin(e)*i+this.yCenter}},draw:function(){if(this.display){var t=this.ctx;if(n(this.yLabels,function(i,e){if(e>0){var s,n=e*(this.drawingArea/this.steps),o=this.yCenter-n;if(this.lineWidth>0)if(t.strokeStyle=this.lineColor,t.lineWidth=this.lineWidth,this.lineArc)t.beginPath(),t.arc(this.xCenter,this.yCenter,n,0,2*Math.PI),t.closePath(),t.stroke();else{t.beginPath();for(var a=0;a<this.valuesCount;a++)s=this.getPointPosition(a,this.calculateCenterOffset(this.min+e*this.stepValue)),0===a?t.moveTo(s.x,s.y):t.lineTo(s.x,s.y);t.closePath(),t.stroke()}if(this.showLabels){if(t.font=T(this.fontSize,this.fontStyle,this.fontFamily),this.showLabelBackdrop){var h=t.measureText(i).width;t.fillStyle=this.backdropColor,t.fillRect(this.xCenter-h/2-this.backdropPaddingX,o-this.fontSize/2-this.backdropPaddingY,h+2*this.backdropPaddingX,this.fontSize+2*this.backdropPaddingY)}t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.fontColor,t.fillText(i,this.xCenter,o)}}},this),!this.lineArc){t.lineWidth=this.angleLineWidth,t.strokeStyle=this.angleLineColor;for(var i=this.valuesCount-1;i>=0;i--){if(this.angleLineWidth>0){var e=this.getPointPosition(i,this.calculateCenterOffset(this.max));t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(e.x,e.y),t.stroke(),t.closePath()}var s=this.getPointPosition(i,this.calculateCenterOffset(this.max)+5);t.font=T(this.pointLabelFontSize,this.pointLabelFontStyle,this.pointLabelFontFamily),t.fillStyle=this.pointLabelFontColor;var o=this.labels.length,a=this.labels.length/2,h=a/2,l=h>i||i>o-h,r=i===h||i===o-h;t.textAlign=0===i?"center":i===a?"center":a>i?"left":"right",t.textBaseline=r?"middle":l?"bottom":"top",t.fillText(this.labels[i],s.x,s.y)}}}}}),s.addEvent(window,"resize",function(){var t;return function(){clearTimeout(t),t=setTimeout(function(){n(e.instances,function(t){t.options.responsive&&t.resize(t.render,!0)})},50)}}()),p?define(function(){return e}):"object"==typeof module&&module.exports&&(module.exports=e),t.Chart=e,e.noConflict=function(){return t.Chart=i,e}}).call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleBeginAtZero:!0,scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,barShowStroke:!0,barStrokeWidth:2,barValueSpacing:5,barDatasetSpacing:1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Bar",defaults:s,initialize:function(t){var s=this.options;this.ScaleClass=i.Scale.extend({offsetGridLines:!0,calculateBarX:function(t,i,e){var n=this.calculateBaseWidth(),o=this.calculateX(e)-n/2,a=this.calculateBarWidth(t);return o+a*i+i*s.barDatasetSpacing+a/2},calculateBaseWidth:function(){return this.calculateX(1)-this.calculateX(0)-2*s.barValueSpacing},calculateBarWidth:function(t){var i=this.calculateBaseWidth()-(t-1)*s.barDatasetSpacing;return i/t}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getBarsAtEvent(t):[];this.eachBars(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),this.BarClass=i.Rectangle.extend({strokeWidth:this.options.barStrokeWidth,showStroke:this.options.barShowStroke,ctx:this.chart.ctx}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,bars:[]};this.datasets.push(s),e.each(i.data,function(n,o){e.isNumber(n)&&s.bars.push(new this.BarClass({value:n,label:t.labels[o],strokeColor:i.strokeColor,fillColor:i.fillColor,highlightFill:i.highlightFill||i.fillColor,highlightStroke:i.highlightStroke||i.strokeColor}))},this)},this),this.buildScale(t.labels),this.BarClass.prototype.base=this.scale.endPoint,this.eachBars(function(t,i,s){e.extend(t,{width:this.scale.calculateBarWidth(this.datasets.length),x:this.scale.calculateBarX(this.datasets.length,s,i),y:this.scale.endPoint}),t.save()},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachBars(function(t){t.save()}),this.render()},eachBars:function(t){e.each(this.datasets,function(i,s){e.each(i.bars,t,this,s)},this)},getBarsAtEvent:function(t){for(var i,s=[],n=e.getRelativePosition(t),o=function(t){s.push(t.bars[i])},a=0;a<this.datasets.length;a++)for(i=0;i<this.datasets[a].bars.length;i++)if(this.datasets[a].bars[i].inRange(n.x,n.y))return e.each(this.datasets,o),s;return s},buildScale:function(t){var i=this,s=function(){var t=[];return i.eachBars(function(i){t.push(i.value)}),t},n={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(s(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.barShowStroke?this.options.barStrokeWidth:0,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(n,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new this.ScaleClass(n)},addData:function(t,i){e.each(t,function(t,s){e.isNumber(t)&&this.datasets[s].bars.push(new this.BarClass({value:t,label:i,x:this.scale.calculateBarX(this.datasets.length,s,this.scale.valuesCount+1),y:this.scale.endPoint,width:this.scale.calculateBarWidth(this.datasets.length),base:this.scale.endPoint,strokeColor:this.datasets[s].strokeColor,fillColor:this.datasets[s].fillColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.bars.shift()},this),this.update()},reflow:function(){e.extend(this.BarClass.prototype,{y:this.scale.endPoint,base:this.scale.endPoint});var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();this.chart.ctx;this.scale.draw(i),e.each(this.datasets,function(t,s){e.each(t.bars,function(t,e){t.base=this.scale.endPoint,t.transition({x:this.scale.calculateBarX(this.datasets.length,s,e),y:this.scale.calculateY(t.value),width:this.scale.calculateBarWidth(this.datasets.length)},i).draw()},this)},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,percentageInnerCutout:50,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Doughnut",defaults:s,initialize:function(t){this.segments=[],this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,this.SegmentArc=i.Arc.extend({ctx:this.chart.ctx,x:this.chart.width/2,y:this.chart.height/2}),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];
e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.calculateTotal(t),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({value:t.value,outerRadius:this.options.animateScale?0:this.outerRadius,innerRadius:this.options.animateScale?0:this.outerRadius/100*this.options.percentageInnerCutout,fillColor:t.color,highlightColor:t.highlight||t.color,showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,startAngle:1.5*Math.PI,circumference:this.options.animateRotate?0:this.calculateCircumference(t.value),label:t.label})),e||(this.reflow(),this.update())},calculateCircumference:function(t){return 2*Math.PI*(t/this.total)},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this)},update:function(){this.calculateTotal(this.segments),e.each(this.activeElements,function(t){t.restore(["fillColor"])}),e.each(this.segments,function(t){t.save()}),this.render()},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.outerRadius=(e.min([this.chart.width,this.chart.height])-this.options.segmentStrokeWidth/2)/2,e.each(this.segments,function(t){t.update({outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout})},this)},draw:function(t){var i=t?t:1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.calculateCircumference(t.value),outerRadius:this.outerRadius,innerRadius:this.outerRadius/100*this.options.percentageInnerCutout},i),t.endAngle=t.startAngle+t.circumference,t.draw(),0===e&&(t.startAngle=1.5*Math.PI),e<this.segments.length-1&&(this.segments[e+1].startAngle=t.endAngle)},this)}}),i.types.Doughnut.extend({name:"Pie",defaults:e.merge(s,{percentageInnerCutout:0})})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowGridLines:!0,scaleGridLineColor:"rgba(0,0,0,.05)",scaleGridLineWidth:1,bezierCurve:!0,bezierCurveTension:.4,pointDot:!0,pointDotRadius:4,pointDotStrokeWidth:1,pointHitDetectionRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"Line",defaults:s,initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx,inRange:function(t){return Math.pow(t-this.x,2)<Math.pow(this.radius+this.hitDetectionRadius,2)}}),this.datasets=[],this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(n,o){e.isNumber(n)&&s.points.push(new this.PointClass({value:n,label:t.labels[o],strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))},this),this.buildScale(t.labels),this.eachPoints(function(t,i){e.extend(t,{x:this.scale.calculateX(i),y:this.scale.endPoint}),t.save()},this)},this),this.render()},update:function(){this.scale.update(),e.each(this.activeElements,function(t){t.restore(["fillColor","strokeColor"])}),this.eachPoints(function(t){t.save()}),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.datasets,function(t){e.each(t.points,function(t){t.inRange(s.x,s.y)&&i.push(t)})},this),i},buildScale:function(t){var s=this,n=function(){var t=[];return s.eachPoints(function(i){t.push(i.value)}),t},o={templateString:this.options.scaleLabel,height:this.chart.height,width:this.chart.width,ctx:this.chart.ctx,textColor:this.options.scaleFontColor,fontSize:this.options.scaleFontSize,fontStyle:this.options.scaleFontStyle,fontFamily:this.options.scaleFontFamily,valuesCount:t.length,beginAtZero:this.options.scaleBeginAtZero,integersOnly:this.options.scaleIntegersOnly,calculateYRange:function(t){var i=e.calculateScaleRange(n(),t,this.fontSize,this.beginAtZero,this.integersOnly);e.extend(this,i)},xLabels:t,font:e.fontString(this.options.scaleFontSize,this.options.scaleFontStyle,this.options.scaleFontFamily),lineWidth:this.options.scaleLineWidth,lineColor:this.options.scaleLineColor,gridLineWidth:this.options.scaleShowGridLines?this.options.scaleGridLineWidth:0,gridLineColor:this.options.scaleShowGridLines?this.options.scaleGridLineColor:"rgba(0,0,0,0)",padding:this.options.showScale?0:this.options.pointDotRadius+this.options.pointDotStrokeWidth,showLabels:this.options.scaleShowLabels,display:this.options.showScale};this.options.scaleOverride&&e.extend(o,{calculateYRange:e.noop,steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}),this.scale=new i.Scale(o)},addData:function(t,i){e.each(t,function(t,s){e.isNumber(t)&&this.datasets[s].points.push(new this.PointClass({value:t,label:i,x:this.scale.calculateX(this.scale.valuesCount+1),y:this.scale.endPoint,strokeColor:this.datasets[s].pointStrokeColor,fillColor:this.datasets[s].pointColor}))},this),this.scale.addXLabel(i),this.update()},removeData:function(){this.scale.removeXLabel(),e.each(this.datasets,function(t){t.points.shift()},this),this.update()},reflow:function(){var t=e.extend({height:this.chart.height,width:this.chart.width});this.scale.update(t)},draw:function(t){var i=t||1;this.clear();var s=this.chart.ctx;this.scale.draw(i),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.transition({y:this.scale.calculateY(t.value),x:this.scale.calculateX(e)},i)},this),this.options.bezierCurve&&e.each(t.points,function(i,s){i.controlPoints=0===s?e.splineCurve(i,i,t.points[s+1],0):s>=t.points.length-1?e.splineCurve(t.points[s-1],i,i,0):e.splineCurve(t.points[s-1],i,t.points[s+1],this.options.bezierCurveTension)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(t.points,function(i,e){e>0?this.options.bezierCurve?s.bezierCurveTo(t.points[e-1].controlPoints.outer.x,t.points[e-1].controlPoints.outer.y,i.controlPoints.inner.x,i.controlPoints.inner.y,i.x,i.y):s.lineTo(i.x,i.y):s.moveTo(i.x,i.y)},this),s.stroke(),this.options.datasetFill&&(s.lineTo(t.points[t.points.length-1].x,this.scale.endPoint),s.lineTo(this.scale.calculateX(0),this.scale.endPoint),s.fillStyle=t.fillColor,s.closePath(),s.fill()),e.each(t.points,function(t){t.draw()})},this)}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers,s={scaleShowLabelBackdrop:!0,scaleBackdropColor:"rgba(255,255,255,0.75)",scaleBeginAtZero:!0,scaleBackdropPaddingY:2,scaleBackdropPaddingX:2,scaleShowLine:!0,segmentShowStroke:!0,segmentStrokeColor:"#fff",segmentStrokeWidth:2,animationSteps:100,animationEasing:"easeOutBounce",animateRotate:!0,animateScale:!1,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<segments.length; i++){%><li><span style="background-color:<%=segments[i].fillColor%>"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>'};i.Type.extend({name:"PolarArea",defaults:s,initialize:function(t){this.segments=[],this.SegmentArc=i.Arc.extend({showStroke:this.options.segmentShowStroke,strokeWidth:this.options.segmentStrokeWidth,strokeColor:this.options.segmentStrokeColor,ctx:this.chart.ctx,innerRadius:0,x:this.chart.width/2,y:this.chart.height/2}),this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,lineArc:!0,width:this.chart.width,height:this.chart.height,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,valuesCount:t.length}),this.updateScaleRange(t),this.scale.update(),e.each(t,function(t,i){this.addData(t,i,!0)},this),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getSegmentsAtEvent(t):[];e.each(this.segments,function(t){t.restore(["fillColor"])}),e.each(i,function(t){t.fillColor=t.highlightColor}),this.showTooltip(i)}),this.render()},getSegmentsAtEvent:function(t){var i=[],s=e.getRelativePosition(t);return e.each(this.segments,function(t){t.inRange(s.x,s.y)&&i.push(t)},this),i},addData:function(t,i,e){var s=i||this.segments.length;this.segments.splice(s,0,new this.SegmentArc({fillColor:t.color,highlightColor:t.highlight||t.color,label:t.label,value:t.value,outerRadius:this.options.animateScale?0:this.scale.calculateCenterOffset(t.value),circumference:this.options.animateRotate?0:this.scale.getCircumference(),startAngle:1.5*Math.PI})),e||(this.reflow(),this.update())},removeData:function(t){var i=e.isNumber(t)?t:this.segments.length-1;this.segments.splice(i,1),this.reflow(),this.update()},calculateTotal:function(t){this.total=0,e.each(t,function(t){this.total+=t.value},this),this.scale.valuesCount=this.segments.length},updateScaleRange:function(t){var i=[];e.each(t,function(t){i.push(t.value)});var s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s,{size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2})},update:function(){this.calculateTotal(this.segments),e.each(this.segments,function(t){t.save()}),this.render()},reflow:function(){e.extend(this.SegmentArc.prototype,{x:this.chart.width/2,y:this.chart.height/2}),this.updateScaleRange(this.segments),this.scale.update(),e.extend(this.scale,{xCenter:this.chart.width/2,yCenter:this.chart.height/2}),e.each(this.segments,function(t){t.update({outerRadius:this.scale.calculateCenterOffset(t.value)})},this)},draw:function(t){var i=t||1;this.clear(),e.each(this.segments,function(t,e){t.transition({circumference:this.scale.getCircumference(),outerRadius:this.scale.calculateCenterOffset(t.value)},i),t.endAngle=t.startAngle+t.circumference,0===e&&(t.startAngle=1.5*Math.PI),e<this.segments.length-1&&(this.segments[e+1].startAngle=t.endAngle),t.draw()},this),this.scale.draw()}})}.call(this),function(){"use strict";var t=this,i=t.Chart,e=i.helpers;i.Type.extend({name:"Radar",defaults:{scaleShowLine:!0,angleShowLineOut:!0,scaleShowLabels:!1,scaleBeginAtZero:!0,angleLineColor:"rgba(0,0,0,.1)",angleLineWidth:1,pointLabelFontFamily:"'Arial'",pointLabelFontStyle:"normal",pointLabelFontSize:10,pointLabelFontColor:"#666",pointDot:!0,pointDotRadius:3,pointDotStrokeWidth:1,pointHitDetectionRadius:20,datasetStroke:!0,datasetStrokeWidth:2,datasetFill:!0,legendTemplate:'<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].strokeColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>'},initialize:function(t){this.PointClass=i.Point.extend({strokeWidth:this.options.pointDotStrokeWidth,radius:this.options.pointDotRadius,display:this.options.pointDot,hitDetectionRadius:this.options.pointHitDetectionRadius,ctx:this.chart.ctx}),this.datasets=[],this.buildScale(t),this.options.showTooltips&&e.bindEvents(this,this.options.tooltipEvents,function(t){var i="mouseout"!==t.type?this.getPointsAtEvent(t):[];this.eachPoints(function(t){t.restore(["fillColor","strokeColor"])}),e.each(i,function(t){t.fillColor=t.highlightFill,t.strokeColor=t.highlightStroke}),this.showTooltip(i)}),e.each(t.datasets,function(i){var s={label:i.label||null,fillColor:i.fillColor,strokeColor:i.strokeColor,pointColor:i.pointColor,pointStrokeColor:i.pointStrokeColor,points:[]};this.datasets.push(s),e.each(i.data,function(n,o){if(e.isNumber(n)){var a;this.scale.animation||(a=this.scale.getPointPosition(o,this.scale.calculateCenterOffset(n))),s.points.push(new this.PointClass({value:n,label:t.labels[o],x:this.options.animation?this.scale.xCenter:a.x,y:this.options.animation?this.scale.yCenter:a.y,strokeColor:i.pointStrokeColor,fillColor:i.pointColor,highlightFill:i.pointHighlightFill||i.pointColor,highlightStroke:i.pointHighlightStroke||i.pointStrokeColor}))}},this)},this),this.render()},eachPoints:function(t){e.each(this.datasets,function(i){e.each(i.points,t,this)},this)},getPointsAtEvent:function(t){var i=e.getRelativePosition(t),s=e.getAngleFromPoint({x:this.scale.xCenter,y:this.scale.yCenter},i),n=2*Math.PI/this.scale.valuesCount,o=Math.round((s.angle-1.5*Math.PI)/n),a=[];return(o>=this.scale.valuesCount||0>o)&&(o=0),s.distance<=this.scale.drawingArea&&e.each(this.datasets,function(t){a.push(t.points[o])}),a},buildScale:function(t){this.scale=new i.RadialScale({display:this.options.showScale,fontStyle:this.options.scaleFontStyle,fontSize:this.options.scaleFontSize,fontFamily:this.options.scaleFontFamily,fontColor:this.options.scaleFontColor,showLabels:this.options.scaleShowLabels,showLabelBackdrop:this.options.scaleShowLabelBackdrop,backdropColor:this.options.scaleBackdropColor,backdropPaddingY:this.options.scaleBackdropPaddingY,backdropPaddingX:this.options.scaleBackdropPaddingX,lineWidth:this.options.scaleShowLine?this.options.scaleLineWidth:0,lineColor:this.options.scaleLineColor,angleLineColor:this.options.angleLineColor,angleLineWidth:this.options.angleShowLineOut?this.options.angleLineWidth:0,pointLabelFontColor:this.options.pointLabelFontColor,pointLabelFontSize:this.options.pointLabelFontSize,pointLabelFontFamily:this.options.pointLabelFontFamily,pointLabelFontStyle:this.options.pointLabelFontStyle,height:this.chart.height,width:this.chart.width,xCenter:this.chart.width/2,yCenter:this.chart.height/2,ctx:this.chart.ctx,templateString:this.options.scaleLabel,labels:t.labels,valuesCount:t.datasets[0].data.length}),this.scale.setScaleSize(),this.updateScaleRange(t.datasets),this.scale.buildYLabels()},updateScaleRange:function(t){var i=function(){var i=[];return e.each(t,function(t){t.data?i=i.concat(t.data):e.each(t.points,function(t){i.push(t.value)})}),i}(),s=this.options.scaleOverride?{steps:this.options.scaleSteps,stepValue:this.options.scaleStepWidth,min:this.options.scaleStartValue,max:this.options.scaleStartValue+this.options.scaleSteps*this.options.scaleStepWidth}:e.calculateScaleRange(i,e.min([this.chart.width,this.chart.height])/2,this.options.scaleFontSize,this.options.scaleBeginAtZero,this.options.scaleIntegersOnly);e.extend(this.scale,s)},addData:function(t,i){this.scale.valuesCount++,e.each(t,function(t,s){if(e.isNumber(t)){var n=this.scale.getPointPosition(this.scale.valuesCount,this.scale.calculateCenterOffset(t));this.datasets[s].points.push(new this.PointClass({value:t,label:i,x:n.x,y:n.y,strokeColor:this.datasets[s].pointStrokeColor,fillColor:this.datasets[s].pointColor}))}},this),this.scale.labels.push(i),this.reflow(),this.update()},removeData:function(){this.scale.valuesCount--,this.scale.labels.shift(),e.each(this.datasets,function(t){t.points.shift()},this),this.reflow(),this.update()},update:function(){this.eachPoints(function(t){t.save()}),this.render()},reflow:function(){e.extend(this.scale,{width:this.chart.width,height:this.chart.height,size:e.min([this.chart.width,this.chart.height]),xCenter:this.chart.width/2,yCenter:this.chart.height/2}),this.updateScaleRange(this.datasets),this.scale.setScaleSize(),this.scale.buildYLabels()},draw:function(t){var i=t||1,s=this.chart.ctx;this.clear(),this.scale.draw(),e.each(this.datasets,function(t){e.each(t.points,function(t,e){t.transition(this.scale.getPointPosition(e,this.scale.calculateCenterOffset(t.value)),i)},this),s.lineWidth=this.options.datasetStrokeWidth,s.strokeStyle=t.strokeColor,s.beginPath(),e.each(t.points,function(t,i){0===i?s.moveTo(t.x,t.y):s.lineTo(t.x,t.y)},this),s.closePath(),s.stroke(),s.fillStyle=t.fillColor,s.fill(),e.each(t.points,function(t){t.draw()})},this)}})}.call(this);
\ No newline at end of file | true |
Other | chartjs | Chart.js | 477e09f1d406b71f0c3f8990da7d0037c427125f.json | Add support for CommonJS module definition | src/Chart.Core.js | @@ -1873,6 +1873,8 @@
define(function(){
return Chart;
});
+ } else if (typeof module === 'object' && module.exports) {
+ module.exports = Chart;
}
root.Chart = Chart; | true |
Other | chartjs | Chart.js | e139ab85969c92916639f6fa026740e3cc8dc0ff.json | Make javascript JavaScript and Github GitHub | docs/00-Getting-Started.md | @@ -11,7 +11,7 @@ First we need to include the Chart.js library on the page. The library occupies
<script src="Chart.js"></script>
```
-Alternatively, if you're using an AMD loader for javascript modules, that is also supported in the Chart.js core. Please note: the library will still occupy a global variable of `Chart`, even if it detects `define` and `define.amd`. If this is a problem, you can call `noConflict` to restore the global Chart variable to it's previous owner.
+Alternatively, if you're using an AMD loader for JavaScript modules, that is also supported in the Chart.js core. Please note: the library will still occupy a global variable of `Chart`, even if it detects `define` and `define.amd`. If this is a problem, you can call `noConflict` to restore the global Chart variable to it's previous owner.
```javascript
// Using requirejs | true |
Other | chartjs | Chart.js | e139ab85969c92916639f6fa026740e3cc8dc0ff.json | Make javascript JavaScript and Github GitHub | docs/06-Advanced.md | @@ -122,7 +122,7 @@ new Chart(ctx).LineAlt(data);
### Creating custom builds
-Chart.js uses <a href="http://gulpjs.com/" target="_blank">gulp</a> to build the library into a single javascript file. We can use this same build script with custom parameters in order to build a custom version.
+Chart.js uses <a href="http://gulpjs.com/" target="_blank">gulp</a> to build the library into a single JavaScript file. We can use this same build script with custom parameters in order to build a custom version.
Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following:
@@ -131,7 +131,7 @@ npm install
npm install -g gulp
```
-This will install the local development dependencies for Chart.js, along with a CLI for the javascript task runner <a href="http://gulpjs.com/" target="_blank">gulp</a>.
+This will install the local development dependencies for Chart.js, along with a CLI for the JavaScript task runner <a href="http://gulpjs.com/" target="_blank">gulp</a>.
Now, we can run the `gulp build` task, and pass in a comma seperated list of types as an argument to build a custom version of Chart.js with only specified chart types.
| true |
Other | chartjs | Chart.js | e139ab85969c92916639f6fa026740e3cc8dc0ff.json | Make javascript JavaScript and Github GitHub | docs/07-Notes.md | @@ -26,7 +26,7 @@ Some important points to note in my experience using ExplorerCanvas as a fallbac
### Bugs & issues
-Please report these on the Github page - at <a href="https://github.com/nnnick/Chart.js" target="_blank">github.com/nnnick/Chart.js</a>. If you could include a link to a simple <a href="http://jsbin.com/" target="_blank">jsbin</a> or similar to demonstrate the issue, that'd be really helpful.
+Please report these on the GitHub page - at <a href="https://github.com/nnnick/Chart.js" target="_blank">github.com/nnnick/Chart.js</a>. If you could include a link to a simple <a href="http://jsbin.com/" target="_blank">jsbin</a> or similar to demonstrate the issue, that'd be really helpful.
### Contributing | true |
Other | chartjs | Chart.js | e24efd23a2bbd9db6197998f9b8f1ab33d1df6f2.json | Add build sequence + dev dependencies | gulpfile.js | @@ -0,0 +1,87 @@
+var gulp = require('gulp'),
+ concat = require('gulp-concat'),
+ uglify = require('gulp-uglify'),
+ util = require('gulp-util'),
+ jshint = require('gulp-jshint'),
+ size = require('gulp-size'),
+ connect = require('gulp-connect'),
+ exec = require('child_process').exec;
+
+var srcDir = './src/';
+/*
+ * Usage : gulp build --types=Bar,Line,Doughnut
+ * Output: - A built Chart.js file with Core and types Bar, Line and Doughnut concatenated together
+ * - A minified version of this code, in Chart.min.js
+ */
+
+gulp.task('build', function(){
+
+ // Default to all of the chart types, with Chart.Core first
+ var srcFiles = [FileName('Core')],
+ isCustom = !!(util.env.types),
+ outputDir = (isCustom) ? 'custom' : '.';
+ if (isCustom){
+ util.env.types.split(',').forEach(function(type){ return srcFiles.push(FileName(type))});
+ }
+ else{
+ // Seems gulp-concat remove duplicates - nice!
+ // So we can use this to sort out dependency order - aka include Core first!
+ srcFiles.push(srcDir+'*');
+ }
+ return gulp.src(srcFiles)
+ .pipe(concat('Chart.js'))
+ .pipe(gulp.dest(outputDir))
+ .pipe(uglify({preserveComments:'some'}))
+ .pipe(concat('Chart.min.js'))
+ .pipe(gulp.dest(outputDir));
+
+ function FileName(moduleName){
+ return srcDir+'Chart.'+moduleName+'.js';
+ };
+});
+
+gulp.task('jshint', function(){
+ return gulp.src(srcDir + '*.js')
+ .pipe(jshint())
+ .pipe(jshint.reporter('default'));
+});
+
+gulp.task('library-size', function(){
+ return gulp.src('Chart.min.js')
+ .pipe(size({
+ gzip: true
+ }));
+});
+
+gulp.task('module-sizes', function(){
+ return gulp.src(srcDir + '*.js')
+ .pipe(uglify({preserveComments:'some'}))
+ .pipe(size({
+ showFiles: true,
+ gzip: true
+ }))
+});
+
+gulp.task('watch', function(){
+ gulp.watch('./src/*', ['build']);
+});
+
+gulp.task('test', ['jshint']);
+
+gulp.task('size', ['library-size', 'module-sizes']);
+
+gulp.task('default', ['build', 'watch']);
+
+gulp.task('server', function(){
+ connect.server({
+ port: 8000,
+ });
+});
+
+// Convenience task for opening the project straight from the command line
+gulp.task('_open', function(){
+ exec('open http://localhost:8000');
+ exec('subl .');
+});
+
+gulp.task('dev', ['server', 'default']); | true |
Other | chartjs | Chart.js | e24efd23a2bbd9db6197998f9b8f1ab33d1df6f2.json | Add build sequence + dev dependencies | package.json | @@ -0,0 +1,21 @@
+{
+ "name": "Chart.js",
+ "homepage": "http://www.chartjs.org",
+ "description": "Simple HTML5 charts using the canvas element.",
+ "private": true,
+ "version": "1.0.0-beta",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/nnnick/Chart.js.git"
+ },
+ "dependences": {},
+ "devDependencies": {
+ "gulp": "3.5.x",
+ "gulp-concat": "~2.1.x",
+ "gulp-uglify": "~0.2.x",
+ "gulp-util": "~2.2.x",
+ "gulp-jshint": "~1.5.1",
+ "gulp-size": "~0.4.0",
+ "gulp-connect": "~2.0.5"
+ }
+} | true |
Other | chartjs | Chart.js | dc6d5bc934f582d32abb89abc506738d80e29548.json | Add new docs as markdown files | docs/00-Getting-Started.md | @@ -0,0 +1,197 @@
+---
+title: Getting started
+anchor: getting-started
+---
+
+###Include Chart.js
+
+First we need to include the Chart.js library on the page. The library occupies a global variable of `Chart`.
+
+```html
+<script src="Chart.js"></script>
+```
+
+Alternatively, if you're using an AMD loader for javascript modules, that is also supported in the Chart.js core. Please note: the library will still occupy a global variable of `Chart`, even if it detects `define` and `define.amd`. If this is a problem, you can call `noConflict` to restore the global Chart variable to it's previous owner.
+
+```javascript
+// Using requirejs
+require(['path/to/Chartjs'], function(Chart){
+ // Use Chart.js as normal here.
+
+ // Chart.noConflict restores the Chart global variable to it's previous owner
+ // The function returns what was previously Chart, allowing you to reassign.
+ var Chartjs = Chart.noConflict();
+
+});
+```
+
+You can also grab Chart.js using bower:
+
+```bash
+bower install chartjs --save
+```
+
+###Creating a chart
+
+To create a chart, we need to instantiate the `Chart` class. To do this, we need to pass in the 2d context of where we want to draw the chart. Here's an example.
+
+```html
+<canvas id="myChart" width="400" height="400"></canvas>
+```
+
+```javascript
+// Get the context of the canvas element we want to select
+var ctx = document.getElementById("myChart").getContext("2d");
+var myNewChart = new Chart(ctx).PolarArea(data);
+```
+
+We can also get the context of our canvas with jQuery. To do this, we need to get the DOM node out of the jQuery collection, and call the `getContext("2d")` method on that.
+
+```javascript
+// Get context with jQuery - using jQuery's .get() method.
+var ctx = $("#myChart").get(0).getContext("2d");
+// This will get the first returned node in the jQuery collection.
+var myNewChart = new Chart(ctx);
+```
+
+After we've instantiated the Chart class on the canvas we want to draw on, Chart.js will handle the scaling for retina displays.
+
+With the Chart class set up, we can go on to create one of the charts Chart.js has available. In the example below, we would be drawing a Polar area chart.
+
+```javascript
+new Chart(ctx).PolarArea(data, options);
+```
+
+We call a method of the name of the chart we want to create. We pass in the data for that chart type, and the options for that chart as parameters. Chart.js will merge the global defaults with chart type specific defaults, then merge any options passed in as a second argument after data.
+
+###Global chart configuration
+
+This concept was introduced in Chart.js 1.0 to keep configuration DRY, and allow for changing options globally across chart types, avoiding the need to specify options for each instance, or the default for a particular chart type.
+
+```javascript
+Chart.defaults.global = {
+ // Boolean - Whether to animate the chart
+ animation: true,
+
+ // Number - Number of animation steps
+ animationSteps: 60,
+
+ // String - Animation easing effect
+ animationEasing: "easeOutQuart",
+
+ // Boolean - If we should show the scale at all
+ showScale: true,
+
+ // Boolean - If we want to override with a hard coded scale
+ scaleOverride: false,
+
+ // ** Required if scaleOverride is true **
+ // Number - The number of steps in a hard coded scale
+ scaleSteps: null,
+ // Number - The value jump in the hard coded scale
+ scaleStepWidth: null,
+ // Number - The scale starting value
+ scaleStartValue: null,
+
+ // String - Colour of the scale line
+ scaleLineColor: "rgba(0,0,0,.1)",
+
+ // Number - Pixel width of the scale line
+ scaleLineWidth: 1,
+
+ // Boolean - Whether to show labels on the scale
+ scaleShowLabels: true,
+
+ // Interpolated JS string - can access value
+ scaleLabel: "<%=value%>",
+
+ // Boolean - Whether the scale should stick to integers, not floats even if drawing space is there
+ scaleIntegersOnly: true,
+
+ // Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
+ scaleBeginAtZero: false,
+
+ // String - Scale label font declaration for the scale label
+ scaleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+
+ // Number - Scale label font size in pixels
+ scaleFontSize: 12,
+
+ // String - Scale label font weight style
+ scaleFontStyle: "normal",
+
+ // String - Scale label font colour
+ scaleFontColor: "#666",
+
+ // Boolean - whether or not the chart should be responsive and resize when the browser does.
+ responsive: false,
+
+ // Boolean - Determines whether to draw tooltips on the canvas or not
+ showTooltips: true,
+
+ // Array - Array of string names to attach tooltip events
+ tooltipEvents: ["mousemove", "touchstart", "touchmove"],
+
+ // String - Tooltip background colour
+ tooltipFillColor: "rgba(0,0,0,0.8)",
+
+ // String - Tooltip label font declaration for the scale label
+ tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+
+ // Number - Tooltip label font size in pixels
+ tooltipFontSize: 14,
+
+ // String - Tooltip font weight style
+ tooltipFontStyle: "normal",
+
+ // String - Tooltip label font colour
+ tooltipFontColor: "#fff",
+
+ // String - Tooltip title font declaration for the scale label
+ tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",
+
+ // Number - Tooltip title font size in pixels
+ tooltipTitleFontSize: 14,
+
+ // String - Tooltip title font weight style
+ tooltipTitleFontStyle: "bold",
+
+ // String - Tooltip title font colour
+ tooltipTitleFontColor: "#fff",
+
+ // Number - pixel width of padding around tooltip text
+ tooltipYPadding: 6,
+
+ // Number - pixel width of padding around tooltip text
+ tooltipXPadding: 6,
+
+ // Number - Size of the caret on the tooltip
+ tooltipCaretSize: 8,
+
+ // Number - Pixel radius of the tooltip border
+ tooltipCornerRadius: 6,
+
+ // Number - Pixel offset from point x to tooltip edge
+ tooltipXOffset: 10,
+ {% raw %}
+ // String - Template string for single tooltips
+ tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>",
+ {% endraw %}
+ // String - Template string for single tooltips
+ multiTooltipTemplate: "<%= value %>",
+
+ // Function - Will fire on animation progression.
+ onAnimationProgress: function(){},
+
+ // Function - Will fire on animation completion.
+ onAnimationComplete: function(){}
+}
+```
+
+If for example, you wanted all charts created to be responsive, and resize when the browser window does, the following setting can be changed:
+
+```javascript
+Chart.defaults.global.responsive = true;
+```
+
+Now, every time we create a chart, `options.responsive` will be `true`. | true |
Other | chartjs | Chart.js | dc6d5bc934f582d32abb89abc506738d80e29548.json | Add new docs as markdown files | docs/01-Line-Chart.md | @@ -0,0 +1,160 @@
+---
+title: Line Chart
+anchor: line-chart
+---
+###Introduction
+A line chart is a way of plotting data points on a line.
+
+Often, it is used to show trend data, and the comparison of two data sets.
+
+<div class="canvas-holder">
+ <canvas width="250" height="125"></canvas>
+</div>
+
+###Example usage
+```javascript
+var myLineChart = new Chart(ctx).Line(data, options);
+```
+###Data structure
+
+```javascript
+var data = {
+ labels: ["January", "February", "March", "April", "May", "June", "July"],
+ datasets: [
+ {
+ label: "My First dataset",
+ fillColor: "rgba(220,220,220,0.2)",
+ strokeColor: "rgba(220,220,220,1)",
+ pointColor: "rgba(220,220,220,1)",
+ pointStrokeColor: "#fff",
+ pointHighlightFill: "#fff",
+ pointHighlightStroke: "rgba(220,220,220,1)",
+ data: [65, 59, 80, 81, 56, 55, 40]
+ },
+ {
+ label: "My Second dataset",
+ fillColor: "rgba(151,187,205,0.2)",
+ strokeColor: "rgba(151,187,205,1)",
+ pointColor: "rgba(151,187,205,1)",
+ pointStrokeColor: "#fff",
+ pointHighlightFill: "#fff",
+ pointHighlightStroke: "rgba(151,187,205,1)",
+ data: [28, 48, 40, 19, 86, 27, 90]
+ }
+ ]
+};
+```
+
+The line chart requires an array of labels for each of the data points. This is shown on the X axis.
+The data for line charts is broken up into an array of datasets. Each dataset has a colour for the fill, a colour for the line and colours for the points and strokes of the points. These colours are strings just like CSS. You can use RGBA, RGB, HEX or HSL notation.
+
+The label key on each dataset is optional, and can be used when generating a scale for the chart.
+
+### Chart options
+
+These are the customisation options specific to Line charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+
+```javascript
+{
+
+ ///Boolean - Whether grid lines are shown across the chart
+ scaleShowGridLines : true,
+
+ //String - Colour of the grid lines
+ scaleGridLineColor : "rgba(0,0,0,.05)",
+
+ //Number - Width of the grid lines
+ scaleGridLineWidth : 1,
+
+ //Boolean - Whether the line is curved between points
+ bezierCurve : true,
+
+ //Number - Tension of the bezier curve between points
+ bezierCurveTension : 0.4,
+
+ //Boolean - Whether to show a dot for each point
+ pointDot : true,
+
+ //Number - Radius of each point dot in pixels
+ pointDotRadius : 4,
+
+ //Number - Pixel width of point dot stroke
+ pointDotStrokeWidth : 1,
+
+ //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
+ pointHitDetectionRadius : 20,
+
+ //Boolean - Whether to show a stroke for datasets
+ datasetStroke : true,
+
+ //Number - Pixel width of dataset stroke
+ datasetStrokeWidth : 2,
+
+ //Boolean - Whether to fill the dataset with a colour
+ datasetFill : true,
+ {% raw %}
+ //String - A legend template
+ legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
+ {% endraw %}
+};
+```
+
+You can override these for your `Chart` instance by passing a second argument into the `Line` method as an object with the keys you want to override.
+
+For example, we could have a line chart without bezier curves between points by doing the following:
+
+```javascript
+new Chart(ctx).Line(data, {
+ bezierCurve: false
+});
+// This will create a chart with all of the default options, merged from the global config,
+// and the Line chart defaults, but this particular instance will have `bezierCurve` set to false.
+```
+
+We can also change these defaults values for each Line type that is created, this object is available at `Chart.defaults.Line`.
+
+
+### Prototype methods
+
+#### .getPointsAtEvent( event )
+
+Calling `getPointsAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the point elements that are at that the same position of that event.
+
+```javascript
+canvas.onclick = function(evt){
+ var activePoints = myLineChart.getPointsAtEvent(evt);
+ // => activePoints is an array of points on the canvas that are at the same position as the click event.
+};
+```
+
+This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application.
+
+#### .update( )
+
+Calling `update()` on your Chart instance will re-render the chart with any updated values, allowing you to edit the value of multiple existing points, then render those in one animated render loop.
+
+```javascript
+myLineChart.datasets[0].points[2].value = 50;
+// Would update the first dataset's value of 'March' to be 50
+myLineChart.update();
+// Calling update now animates the position of March from 90 to 50.
+```
+
+#### .addData( valuesArray, label )
+
+Calling `addData(valuesArray, label)` on your Chart instance passing an array of values for each dataset, along with a label for those points.
+
+```javascript
+// The values array passed into addData should be one for each dataset in the chart
+myLineChart.addData([40, 60], "August");
+// This new data will now animate at the end of the chart.
+```
+
+#### .removeData( )
+
+Calling `removeData()` on your Chart instance will remove the first value for all datasets on the chart.
+
+```javascript
+myLineChart.removeData();
+// The chart will remove the first point and animate other points into place
+``` | true |
Other | chartjs | Chart.js | dc6d5bc934f582d32abb89abc506738d80e29548.json | Add new docs as markdown files | docs/02-Bar-Chart.md | @@ -0,0 +1,143 @@
+---
+title: Bar Chart
+anchor: bar-chart
+---
+
+### Introduction
+A bar chart is a way of showing data as bars.
+
+It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
+
+<div class="canvas-holder">
+ <canvas width="250" height="125"></canvas>
+</div>
+
+### Example usage
+```javascript
+var myBarChart = new Chart(ctx).Bar(data, options);
+```
+
+### Data structure
+
+```javascript
+var data = {
+ labels: ["January", "February", "March", "April", "May", "June", "July"],
+ datasets: [
+ {
+ label: "My First dataset",
+ fillColor: "rgba(220,220,220,0.5)",
+ strokeColor: "rgba(220,220,220,0.8)",
+ highlightFill: "rgba(220,220,220,0.75)",
+ highlightStroke: "rgba(220,220,220,1)",
+ data: [65, 59, 80, 81, 56, 55, 40]
+ },
+ {
+ label: "My Second dataset",
+ fillColor: "rgba(151,187,205,0.5)",
+ strokeColor: "rgba(151,187,205,0.8)",
+ highlightFill: "rgba(151,187,205,0.75)",
+ highlightStroke: "rgba(151,187,205,1)",
+ data: [28, 48, 40, 19, 86, 27, 90]
+ }
+ ]
+};
+```
+The bar chart has the a very similar data structure to the line chart, and has an array of datasets, each with colours and an array of data. Again, colours are in CSS format.
+We have an array of labels too for display. In the example, we are showing the same data as the previous line chart example.
+
+The label key on each dataset is optional, and can be used when generating a scale for the chart.
+
+### Chart Options
+
+These are the customisation options specific to Bar charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+
+```javascript
+{
+ //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
+ scaleBeginAtZero : true,
+
+ //Boolean - Whether grid lines are shown across the chart
+ scaleShowGridLines : true,
+
+ //String - Colour of the grid lines
+ scaleGridLineColor : "rgba(0,0,0,.05)",
+
+ //Number - Width of the grid lines
+ scaleGridLineWidth : 1,
+
+ //Boolean - If there is a stroke on each bar
+ barShowStroke : true,
+
+ //Number - Pixel width of the bar stroke
+ barStrokeWidth : 2,
+
+ //Number - Spacing between each of the X value sets
+ barValueSpacing : 5,
+
+ //Number - Spacing between data sets within X values
+ barDatasetSpacing : 1,
+ {% raw %}
+ //String - A legend template
+ legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
+ {% endraw %}
+}
+```
+
+You can override these for your `Chart` instance by passing a second argument into the `Bar` method as an object with the keys you want to override.
+
+For example, we could have a bar chart without a stroke on each bar by doing the following:
+
+```javascript
+new Chart(ctx).Bar(data, {
+ barShowStroke: false
+});
+// This will create a chart with all of the default options, merged from the global config,
+// and the Bar chart defaults but this particular instance will have `barShowStroke` set to false.
+```
+
+We can also change these defaults values for each Bar type that is created, this object is available at `Chart.defaults.Bar`.
+
+### Prototype methods
+
+#### .getBarsAtEvent( event )
+
+Calling `getBarsAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the bar elements that are at that the same position of that event.
+
+```javascript
+canvas.onclick = function(evt){
+ var activeBars = myBarChart.getBarsAtEvent(evt);
+ // => activeBars is an array of bars on the canvas that are at the same position as the click event.
+};
+```
+
+This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application.
+
+#### .update( )
+
+Calling `update()` on your Chart instance will re-render the chart with any updated values, allowing you to edit the value of multiple existing points, then render those in one animated render loop.
+
+```javascript
+myBarChart.datasets[0].bars[2].value = 50;
+// Would update the first dataset's value of 'March' to be 50
+myBarChart.update();
+// Calling update now animates the position of March from 90 to 50.
+```
+
+#### .addData( valuesArray, label )
+
+Calling `addData(valuesArray, label)` on your Chart instance passing an array of values for each dataset, along with a label for those bars.
+
+```javascript
+// The values array passed into addData should be one for each dataset in the chart
+myBarChart.addData([40, 60], "August");
+// The new data will now animate at the end of the chart.
+```
+
+#### .removeData( )
+
+Calling `removeData()` on your Chart instance will remove the first value for all datasets on the chart.
+
+```javascript
+myBarChart.removeData();
+// The chart will now animate and remove the first bar
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | dc6d5bc934f582d32abb89abc506738d80e29548.json | Add new docs as markdown files | docs/03-Radar-Chart.md | @@ -0,0 +1,177 @@
+---
+title: Radar Chart
+anchor: radar-chart
+---
+
+###Introduction
+A radar chart is a way of showing multiple data points and the variation between them.
+
+They are often useful for comparing the points of two or more different data sets.
+
+<div class="canvas-holder">
+ <canvas width="250" height="125"></canvas>
+</div>
+
+###Example usage
+
+```javascript
+var myRadarChart = new Chart(ctx).Radar(data, options);
+```
+
+###Data structure
+```javascript
+var data = {
+ labels: ["Eating", "Drinking", "Sleeping", "Designing", "Coding", "Cycling", "Running"],
+ datasets: [
+ {
+ label: "My First dataset",
+ fillColor: "rgba(220,220,220,0.2)",
+ strokeColor: "rgba(220,220,220,1)",
+ pointColor: "rgba(220,220,220,1)",
+ pointStrokeColor: "#fff",
+ pointHighlightFill: "#fff",
+ pointHighlightStroke: "rgba(220,220,220,1)",
+ data: [65, 59, 90, 81, 56, 55, 40]
+ },
+ {
+ label: "My Second dataset",
+ fillColor: "rgba(151,187,205,0.2)",
+ strokeColor: "rgba(151,187,205,1)",
+ pointColor: "rgba(151,187,205,1)",
+ pointStrokeColor: "#fff",
+ pointHighlightFill: "#fff",
+ pointHighlightStroke: "rgba(151,187,205,1)",
+ data: [28, 48, 40, 19, 96, 27, 100]
+ }
+ ]
+};
+```
+For a radar chart, to provide context of what each point means, we include an array of strings that show around each point in the chart.
+For the radar chart data, we have an array of datasets. Each of these is an object, with a fill colour, a stroke colour, a colour for the fill of each point, and a colour for the stroke of each point. We also have an array of data values.
+
+The label key on each dataset is optional, and can be used when generating a scale for the chart.
+
+### Chart options
+
+These are the customisation options specific to Radar charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+
+
+```javascript
+{
+ //Boolean - Whether to show lines for each scale point
+ scaleShowLine : true,
+
+ //Boolean - Whether we show the angle lines out of the radar
+ angleShowLineOut : true,
+
+ //Boolean - Whether to show labels on the scale
+ scaleShowLabels : false,
+
+ // Boolean - Whether the scale should begin at zero
+ scaleBeginAtZero : true,
+
+ //String - Colour of the angle line
+ angleLineColor : "rgba(0,0,0,.1)",
+
+ //Number - Pixel width of the angle line
+ angleLineWidth : 1,
+
+ //String - Point label font declaration
+ pointLabelFontFamily : "'Arial'",
+
+ //String - Point label font weight
+ pointLabelFontStyle : "normal",
+
+ //Number - Point label font size in pixels
+ pointLabelFontSize : 10,
+
+ //String - Point label font colour
+ pointLabelFontColor : "#666",
+
+ //Boolean - Whether to show a dot for each point
+ pointDot : true,
+
+ //Number - Radius of each point dot in pixels
+ pointDotRadius : 3,
+
+ //Number - Pixel width of point dot stroke
+ pointDotStrokeWidth : 1,
+
+ //Number - amount extra to add to the radius to cater for hit detection outside the drawn point
+ pointHitDetectionRadius : 20,
+
+ //Boolean - Whether to show a stroke for datasets
+ datasetStroke : true,
+
+ //Number - Pixel width of dataset stroke
+ datasetStrokeWidth : 2,
+
+ //Boolean - Whether to fill the dataset with a colour
+ datasetFill : true,
+ {% raw %}
+ //String - A legend template
+ legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%=datasets[i].lineColor%>\"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>"
+ {% endraw %}
+}
+```
+
+
+You can override these for your `Chart` instance by passing a second argument into the `Radar` method as an object with the keys you want to override.
+
+For example, we could have a radar chart without a point for each on piece of data by doing the following:
+
+```javascript
+new Chart(ctx).Radar(data, {
+ pointDot: false
+});
+// This will create a chart with all of the default options, merged from the global config,
+// and the Bar chart defaults but this particular instance will have `pointDot` set to false.
+```
+
+We can also change these defaults values for each Radar type that is created, this object is available at `Chart.defaults.Radar`.
+
+
+### Prototype methods
+
+#### .getPointsAtEvent( event )
+
+Calling `getPointsAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the point elements that are at that the same position of that event.
+
+```javascript
+canvas.onclick = function(evt){
+ var activePoints = myRadarChart.getPointsAtEvent(evt);
+ // => activePoints is an array of points on the canvas that are at the same position as the click event.
+};
+```
+
+This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application.
+
+#### .update( )
+
+Calling `update()` on your Chart instance will re-render the chart with any updated values, allowing you to edit the value of multiple existing points, then render those in one animated render loop.
+
+```javascript
+myRadarChart.datasets[0].points[2].value = 50;
+// Would update the first dataset's value of 'Sleeping' to be 50
+myRadarChart.update();
+// Calling update now animates the position of Sleeping from 90 to 50.
+```
+
+#### .addData( valuesArray, label )
+
+Calling `addData(valuesArray, label)` on your Chart instance passing an array of values for each dataset, along with a label for those points.
+
+```javascript
+// The values array passed into addData should be one for each dataset in the chart
+myRadarChart.addData([40, 60], "Dancing");
+// The new data will now animate at the end of the chart.
+```
+
+#### .removeData( )
+
+Calling `removeData()` on your Chart instance will remove the first value for all datasets on the chart.
+
+```javascript
+myRadarChart.removeData();
+// Other points will now animate to their correct positions.
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | dc6d5bc934f582d32abb89abc506738d80e29548.json | Add new docs as markdown files | docs/04-Polar-Area-Chart.md | @@ -0,0 +1,172 @@
+---
+title: Polar Area Chart
+anchor: polar-area-chart
+---
+### Introduction
+Polar area charts are similar to pie charts, but each segment has the same angle - the radius of the segment differs depending on the value.
+
+This type of chart is often useful when we want to show a comparison data similar to a pie chart, but also show a scale of values for context.
+
+<div class="canvas-holder">
+ <canvas width="250" height="125"></canvas>
+</div>
+
+### Example usage
+
+```javascript
+new Chart(ctx).PolarArea(data, options);
+```
+
+### Data structure
+
+```javascript
+var data = [
+ {
+ value: 300,
+ color:"#F7464A",
+ highlight: "#FF5A5E",
+ label: "Red"
+ },
+ {
+ value: 50,
+ color: "#46BFBD",
+ highlight: "#5AD3D1",
+ label: "Green"
+ },
+ {
+ value: 100,
+ color: "#FDB45C",
+ highlight: "#FFC870",
+ label: "Yellow"
+ },
+ {
+ value: 40,
+ color: "#949FB1",
+ highlight: "#A8B3C5",
+ label: "Grey"
+ },
+ {
+ value: 120,
+ color: "#4D5360",
+ highlight: "#616774",
+ label: "Dark Grey"
+ }
+
+];
+```
+As you can see, for the chart data you pass in an array of objects, with a value and a colour. The value attribute should be a number, while the color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL.
+
+### Chart options
+
+These are the customisation options specific to Polar Area charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+
+```javascript
+{
+ //Boolean - Show a backdrop to the scale label
+ scaleShowLabelBackdrop : true,
+
+ //String - The colour of the label backdrop
+ scaleBackdropColor : "rgba(255,255,255,0.75)",
+
+ // Boolean - Whether the scale should begin at zero
+ scaleBeginAtZero : true,
+
+ //Number - The backdrop padding above & below the label in pixels
+ scaleBackdropPaddingY : 2,
+
+ //Number - The backdrop padding to the side of the label in pixels
+ scaleBackdropPaddingX : 2,
+
+ //Boolean - Show line for each value in the scale
+ scaleShowLine : true,
+
+ //Boolean - Stroke a line around each segment in the chart
+ segmentShowStroke : true,
+
+ //String - The colour of the stroke on each segement.
+ segmentStrokeColor : "#fff",
+
+ //Number - The width of the stroke value in pixels
+ segmentStrokeWidth : 2,
+
+ //Number - Amount of animation steps
+ animationSteps : 100,
+
+ //String - Animation easing effect.
+ animationEasing : "easeOutBounce",
+
+ //Boolean - Whether to animate the rotation of the chart
+ animateRotate : true,
+
+ //Boolean - Whether to animate scaling the chart from the centre
+ animateScale : false,
+ {% raw %}
+ //String - A legend template
+ legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
+ {% endraw %}
+}
+```
+
+You can override these for your `Chart` instance by passing a second argument into the `PolarArea` method as an object with the keys you want to override.
+
+For example, we could have a polar area chart with a black stroke on each segment like so:
+
+```javascript
+new Chart(ctx).PolarArea(data, {
+ segmentStrokeColor: "#000000"
+});
+// This will create a chart with all of the default options, merged from the global config,
+// and the PolarArea chart defaults but this particular instance will have `segmentStrokeColor` set to `"#000000"`.
+```
+
+We can also change these defaults values for each PolarArea type that is created, this object is available at `Chart.defaults.PolarArea`.
+
+### Prototype methods
+
+#### .getSegmentsAtEvent( event )
+
+Calling `getSegmentsAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the segment elements that are at that the same position of that event.
+
+```javascript
+canvas.onclick = function(evt){
+ var activePoints = myPolarAreaChart.getSegmentsAtEvent(evt);
+ // => activePoints is an array of segments on the canvas that are at the same position as the click event.
+};
+```
+
+This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application.
+
+#### .update( )
+
+Calling `update()` on your Chart instance will re-render the chart with any updated values, allowing you to edit the value of multiple existing points, then render those in one animated render loop.
+
+```javascript
+myPolarAreaChart.segments[1].value = 10;
+// Would update the first dataset's value of 'Green' to be 10
+myPolarAreaChart.update();
+// Calling update now animates the position of Green from 50 to 10.
+```
+
+#### .addData( segmentData, index )
+
+Calling `addData(segmentData, index)` on your Chart instance passing an object in the same format as in the constructor. There is an option second argument of 'index', this determines at what index the new segment should be inserted into the chart.
+
+```javascript
+// An object in the same format as the original data source
+myPolarAreaChart.addData({
+ value: 130,
+ color: "#B48EAD",
+ highlight: "#C69CBE",
+ label: "Purple"
+});
+// The new segment will now animate in.
+```
+
+#### .removeData( index )
+
+Calling `removeData(index)` on your Chart instance will remove segment at that particular index. If none is provided, it will default to the last segment.
+
+```javascript
+myPolarAreaChart.removeData();
+// Other segments will update to fill the empty space left.
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | dc6d5bc934f582d32abb89abc506738d80e29548.json | Add new docs as markdown files | docs/05-Pie-Doughnut-Chart.md | @@ -0,0 +1,158 @@
+---
+title: Pie & Doughnut Charts
+anchor: doughnut-pie-chart
+---
+###Introduction
+Pie and doughnut charts are probably the most commonly used chart there are. They are divided into segments, the arc of each segment shows a the proportional value of each piece of data.
+
+They are excellent at showing the relational proportions between data.
+
+Pie and doughnut charts in are effectively the same class in Chart.js, but have one different default value - their `percentageInnerCutout`. This equates what percentage of the inner should be cut out. This defaults to `0` for pie charts, and `50` for doughnuts.
+
+They are also registered under two aliases in the `Chart` core. Other than their different default value, and different alias, they are exactly the same.
+
+<div class="canvas-holder half">
+ <canvas width="250" height="125"></canvas>
+</div>
+
+<div class="canvas-holder half">
+ <canvas width="250" height="125"></canvas>
+</div>
+
+
+### Example usage
+
+```javascript
+// For a pie chart
+var myPieChart = new Chart(ctx[0]).Pie(data,options);
+
+// And for a doughnut chart
+var myDoughnutChart = new Chart(ctx[1]).Doughnut(data,options);
+```
+
+### Data structure
+
+```javascript
+var data = [
+ {
+ value: 300,
+ color:"#F7464A",
+ highlight: "#FF5A5E",
+ label: "Red"
+ },
+ {
+ value: 50,
+ color: "#46BFBD",
+ highlight: "#5AD3D1",
+ label: "Green"
+ },
+ {
+ value: 100,
+ color: "#FDB45C",
+ highlight: "#FFC870",
+ label: "Yellow"
+ }
+]
+```
+
+For a pie chart, you must pass in an array of objects with a value and a color property. The value attribute should be a number, Chart.js will total all of the numbers and calculate the relative proportion of each. The color attribute should be a string. Similar to CSS, for this string you can use HEX notation, RGB, RGBA or HSL.
+
+### Chart options
+
+These are the customisation options specific to Pie & Doughnut charts. These options are merged with the [global chart configuration options](#getting-started-global-chart-configuration), and form the options of the chart.
+
+```javascript
+{
+ //Boolean - Whether we should show a stroke on each segment
+ segmentShowStroke : true,
+
+ //String - The colour of each segment stroke
+ segmentStrokeColor : "#fff",
+
+ //Number - The width of each segment stroke
+ segmentStrokeWidth : 2,
+
+ //Number - The percentage of the chart that we cut out of the middle
+ percentageInnerCutout : 50, // This is 0 for Pie charts
+
+ //Number - Amount of animation steps
+ animationSteps : 100,
+
+ //String - Animation easing effect
+ animationEasing : "easeOutBounce",
+
+ //Boolean - Whether we animate the rotation of the Doughnut
+ animateRotate : true,
+
+ //Boolean - Whether we animate scaling the Doughnut from the centre
+ animateScale : false,
+ {% raw %}
+ //String - A legend template
+ legendTemplate : "<ul class=\"<%=name.toLowerCase()%>-legend\"><% for (var i=0; i<segments.length; i++){%><li><span style=\"background-color:<%=segments[i].fillColor%>\"></span><%if(segments[i].label){%><%=segments[i].label%><%}%></li><%}%></ul>"
+ {% endraw %}
+}
+```
+You can override these for your `Chart` instance by passing a second argument into the `Doughnut` method as an object with the keys you want to override.
+
+For example, we could have a doughnut chart that animates by scaling out from the centre like so:
+
+```javascript
+new Chart(ctx).Doughnut(data, {
+ animateScale: true
+});
+// This will create a chart with all of the default options, merged from the global config,
+// and the Doughnut chart defaults but this particular instance will have `animateScale` set to `true`.
+```
+
+We can also change these defaults values for each Doughnut type that is created, this object is available at `Chart.defaults.Doughnut`. Pie charts also have a clone of these defaults available to change at `Chart.defaults.Pie`, with the only difference being `percentageInnerCutout` being set to 0.
+
+### Prototype methods
+
+#### .getSegmentsAtEvent( event )
+
+Calling `getSegmentsAtEvent(event)` on your Chart instance passing an argument of an event, or jQuery event, will return the segment elements that are at that the same position of that event.
+
+```javascript
+canvas.onclick = function(evt){
+ var activePoints = myDoughnutChart.getSegmentsAtEvent(evt);
+ // => activePoints is an array of segments on the canvas that are at the same position as the click event.
+};
+```
+
+This functionality may be useful for implementing DOM based tooltips, or triggering custom behaviour in your application.
+
+#### .update( )
+
+Calling `update()` on your Chart instance will re-render the chart with any updated values, allowing you to edit the value of multiple existing points, then render those in one animated render loop.
+
+```javascript
+myDoughnutChart.segments[1].value = 10;
+// Would update the first dataset's value of 'Green' to be 10
+myDoughnutChart.update();
+// Calling update now animates the circumference of the segment 'Green' from 50 to 10.
+// and transitions other segment widths
+```
+
+#### .addData( segmentData, index )
+
+Calling `addData(segmentData, index)` on your Chart instance passing an object in the same format as in the constructor. There is an option second argument of 'index', this determines at what index the new segment should be inserted into the chart.
+
+```javascript
+// An object in the same format as the original data source
+myDoughnutChart.addData({
+ value: 130,
+ color: "#B48EAD",
+ highlight: "#C69CBE",
+ label: "Purple"
+});
+// The new segment will now animate in.
+```
+
+#### .removeData( index )
+
+Calling `removeData(index)` on your Chart instance will remove segment at that particular index. If none is provided, it will default to the last segment.
+
+```javascript
+myDoughnutChart.removeData();
+// Other segments will update to fill the empty space left.
+```
\ No newline at end of file | true |
Other | chartjs | Chart.js | dc6d5bc934f582d32abb89abc506738d80e29548.json | Add new docs as markdown files | docs/06-Advanced.md | @@ -0,0 +1,144 @@
+---
+title: Advanced usage
+anchor: advanced-usage
+---
+
+
+### Prototype methods
+
+For each chart, there are a set of global prototype methods on the shared `ChartType` which you may find useful. These are available on all charts created with Chart.js, but for the examples, let's use a line chart we've made.
+
+```javascript
+// For example:
+var myLineChart = new Chart(ctx).Line(data);
+```
+
+#### .clear()
+
+Will clear the chart canvas. Used extensively internally between animation frames, but you might find it useful.
+
+```javascript
+// Will clear the canvas that myLineChart is drawn on
+myLineChart.clear();
+// => returns 'this' for chainability
+```
+
+#### .stop()
+
+Use this to stop any current animation loop. This will pause the chart during any current animation frame. Call `.render()` to re-animate.
+
+```javascript
+// Stops the charts animation loop at its current frame
+myLineChart.stop();
+// => returns 'this' for chainability
+```
+
+#### .resize()
+
+Use this to manually resize the canvas element. This is run each time the browser is resized, but you can call this method manually if you change the size of the canvas nodes container element.
+
+```javascript
+// Resizes & redraws to fill its container element
+myLineChart.resize();
+// => returns 'this' for chainability
+```
+
+#### .destroy()
+
+Use this to destroy any chart instances that are created. This will clean up any references stored to the chart object within Chart.js, along with any associated event listeners attached by Chart.js.
+
+```javascript
+// Destroys a specific chart instance
+myLineChart.destroy();
+```
+
+#### .toBase64Image()
+
+This returns a base 64 encoded string of the chart in it's current state.
+
+```javascript
+myLineChart.toBase64Image();
+// => returns png data url of the image on the canvas
+```
+
+#### .generateLegend()
+
+Returns an HTML string of a legend for that chart. The template for this legend is at `legendTemplate` in the chart options.
+
+```javascript
+myLineChart.generateLegend();
+// => returns HTML string of a legend for this chart
+```
+
+### Writing new chart types
+
+Chart.js 1.0 has been rewritten to provide a platform for developers to create their own custom chart types, and be able to share and utilise them through the Chart.js API.
+
+The format is relatively simple, there are a set of utility helper methods under `Chart.helpers`, including things such as looping over collections, requesting animation frames, and easing equations.
+
+On top of this, there are also some simple base classes of Chart elements, these all extend from `Chart.Element`, and include things such as points, bars and scales.
+
+```javascript
+Chart.Type.extend({
+ // Passing in a name registers this chart in the Chart namespace
+ name: "Scatter",
+ // Providing a defaults will also register the deafults in the chart namespace
+ defaults : {
+ options: "Here",
+ available: "at this.options"
+ },
+ // Initialize is fired when the chart is initialized - Data is passed in as a parameter
+ // Config is automatically merged by the core of Chart.js, and is available at this.options
+ initialize: function(data){
+ this.chart.ctx // The drawing context for this chart
+ this.chart.canvas // the canvas node for this chart
+ }
+});
+
+// Now we can create a new instance of our chart, using the Chart.js API
+new Chart(ctx).Scatter(data);
+// initialize is now run
+```
+
+### Extending existing chart types
+
+We can also extend existing chart types, and expose them to the API in the same way. Let's say for example, we might want to run some more code when we initialize every Line chart.
+
+```javascript
+// Notice now we're extending the particular Line chart type, rather than the base class.
+Chart.types.Line.extend({
+ // Passing in a name registers this chart in the Chart namespace in the same way
+ name: "LineAlt",
+ initialize: function(data){
+ console.log('My Line chart extension');
+ Chart.types.Line.prototype.apply(this, arguments);
+ }
+});
+
+// Creates a line chart in the same way
+new Chart(ctx).LineAlt(data);
+// but this logs 'My Line chart extension' in the console.
+```
+
+### Creating custom builds
+
+Chart.js uses <a href="http://gulpjs.com/" target="_blank">gulp</a> to build the library into a single javascript file. We can use this same build script with custom parameters in order to build a custom version.
+
+Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following:
+
+```bash
+npm install
+npm install -g gulp
+```
+
+This will install the local development dependencies for Chart.js, along with a CLI for the javascript task runner <a href="http://gulpjs.com/" target="_blank">gulp</a>.
+
+Now, we can run the `gulp build` task, and pass in a comma seperated list of types as an argument to build a custom version of Chart.js with only specified chart types.
+
+Here we will create a version of Chart.js with only Line, Radar and Bar charts included:
+
+```bash
+gulp build --types=Line,Radar,Bar
+```
+
+This will output to the `/custom` directory, and write two files, Chart.js, and Chart.min.js with only those chart types included. | true |
Other | chartjs | Chart.js | dc6d5bc934f582d32abb89abc506738d80e29548.json | Add new docs as markdown files | docs/07-Notes.md | @@ -0,0 +1,42 @@
+---
+title: Notes
+anchor: notes
+---
+
+### Browser support
+Browser support for the canvas element is available in all modern & major mobile browsers <a href="http://caniuse.com/canvas" target="_blank">(caniuse.com/canvas)</a>.
+
+For IE8 & below, I would recommend using the polyfill ExplorerCanvas - available at <a href="https://code.google.com/p/explorercanvas/" target="_blank">https://code.google.com/p/explorercanvas/</a>. It falls back to Internet explorer's format VML when canvas support is not available. Example use:
+
+```html
+<head>
+ <!--[if lte IE 8]>
+ <script src="excanvas.js"></script>
+ <![endif]-->
+</head>
+```
+
+Usually I would recommend feature detection to choose whether or not to load a polyfill, rather than IE conditional comments, however in this case, VML is a Microsoft proprietary format, so it will only work in IE.
+
+Some important points to note in my experience using ExplorerCanvas as a fallback.
+
+- Initialise charts on load rather than DOMContentReady when using the library, as sometimes a race condition will occur, and it will result in an error when trying to get the 2d context of a canvas.
+- New VML DOM elements are being created for each animation frame and there is no hardware acceleration. As a result animation is usually slow and jerky, with flashing text. It is a good idea to dynamically turn off animation based on canvas support. I recommend using the excellent <a href="http://modernizr.com/" target="_blank">Modernizr</a> to do this.
+- When declaring fonts, the library explorercanvas requires the font name to be in single quotes inside the string. For example, instead of your scaleFontFamily property being simply "Arial", explorercanvas support, use "'Arial'" instead. Chart.js does this for default values.
+
+### Bugs & issues
+
+Please report these on the Github page - at <a href="https://github.com/nnnick/Chart.js" target="_blank">github.com/nnnick/Chart.js</a>. If you could include a link to a simple <a href="http://jsbin.com/" target="_blank">jsbin</a> or similar to demonstrate the issue, that'd be really helpful.
+
+
+### Contributing
+New contributions to the library are welcome, just a couple of guidelines:
+
+- Tabs for indentation, not spaces please.
+- Please ensure you're changing the individual files in `/src`, not the concatenated output in the `Chart.js` file in the root of the repo.
+- Please check that your code will pass `jshint` code standards, `gulp jshint` will run this for you.
+- Please keep pull requests concise, and document new functionality in the relevant `.md` file.
+- Consider whether your changes are useful for all users, or if creating a Chart.js extension would be more appropriate.
+
+### License
+Chart.js is open source and available under the <a href="http://opensource.org/licenses/MIT" target="_blank">MIT license</a>.
\ No newline at end of file | true |
Other | chartjs | Chart.js | 0a6c892766abe47e5e535a654b45ab5db052bb76.json | Update copyright year in license to include 2014 | LICENSE.md | @@ -1,4 +1,4 @@
-Copyright (c) 2014 Nick Downie
+Copyright (c) 2013-2014 Nick Downie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
| false |
Other | chartjs | Chart.js | 51032692f335db8b75411a097810b5e7740fc871.json | Update copyright year in license to 2014 | LICENSE.md | @@ -1,4 +1,4 @@
-Copyright (c) 2013 Nick Downie
+Copyright (c) 2014 Nick Downie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
| false |
Other | chartjs | Chart.js | 85f3755f9abd6a1b5224f61cb4e209739f850eed.json | Restore original canvas context when destroying | src/Chart.Core.js | @@ -868,6 +868,21 @@
destroy : function(){
this.clear();
unbindEvents(this, this.events);
+ var canvas = this.chart.canvas;
+
+ // Reset canvas height/width attributes starts a fresh with the canvas context
+ canvas.width = this.chart.width;
+ canvas.height = this.chart.height;
+
+ // < IE9 doesn't support removeProperty
+ if (canvas.style.removeProperty) {
+ canvas.style.removeProperty('width');
+ canvas.style.removeProperty('height');
+ } else {
+ canvas.style.removeAttribute('width');
+ canvas.style.removeAttribute('height');
+ }
+
delete Chart.instances[this.id];
},
showTooltip : function(ChartElements, forceRedraw){ | false |
Other | chartjs | Chart.js | 84e859b6c53b864d251537e76943ae8f72ce3339.json | Remove email notifications | .travis.yml | @@ -11,7 +11,3 @@ script:
- cp Chart.min.js /tmp/OLD
- gulp build
- cmp Chart.min.js /tmp/OLD # ensure build was run before commit
-
-notifications:
- email:
- hello@nickdownie.com | false |
Other | chartjs | Chart.js | 81d4f97abc11420cf16e131e5c169c2baae9a152.json | Remove unnecessary semicolons | src/Chart.Core.js | @@ -238,7 +238,7 @@
if (filterCallback(currentItem)){
return currentItem;
}
- };
+ }
},
findPreviousWhere = helpers.findPreviousWhere = function(arrayToSearch, filterCallback, startIndex){
// Default to end of the array
@@ -250,7 +250,7 @@
if (filterCallback(currentItem)){
return currentItem;
}
- };
+ }
},
inherits = helpers.inherits = function(extensions){
//Basic javascript inheritance based on the model created in Backbone.js | false |
Other | chartjs | Chart.js | 2e4bb1899f32db31b48291a7755d461ca0af0072.json | Fix mixed whitespace | src/Chart.Core.js | @@ -92,8 +92,8 @@
// Boolean - whether or not the chart should be responsive and resize when the browser does.
responsive: false,
- // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
- maintainAspectRatio: true,
+ // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container
+ maintainAspectRatio: true,
// Boolean - Determines whether to draw tooltips on the canvas or not - attaches events to touchmove & mousemove
showTooltips: true,
@@ -441,7 +441,9 @@
//Templating methods
//Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/
template = helpers.template = function(templateString, valuesObject){
- // If templateString is function rather than string-template - call the function for valuesObject
+
+ // If templateString is function rather than string-template - call the function for valuesObject
+
if(templateString instanceof Function){
return templateString(valuesObject);
}
@@ -830,7 +832,7 @@
newHeight = this.options.maintainAspectRatio ? newWidth / this.chart.aspectRatio : getMaximumHeight(this.chart.canvas);
canvas.width = this.chart.width = newWidth;
- canvas.height = this.chart.height = newHeight;
+ canvas.height = this.chart.height = newHeight;
retinaScale(this.chart);
| false |
Other | chartjs | Chart.js | 8c41c5c1b7a6421824c3eb071ea944004403c15f.json | Rewrite contributing guidelines | CONTRIBUTING.md | @@ -1,20 +1,51 @@
-Contributing
-============
+Contributing to Chart.js
+========================
-New contributions to the library are welcome, just a couple of guidelines:
+Contributions to Chart.js are welcome and encouraged, but please have a look through the guidelines in this document before raising an issue, or writing code for the project.
- * Tabs for indentation, not spaces please.
- * Please ensure you're changing the individual files in /src, not the concatenated output in the Chart.js file in the root of the repo.
- * Please check that your code will pass jshint code standards, `gulp jshint` will run this for you.
- * Please keep pull requests concise, and document new functionality in the relevant .md file.
- * Consider whether your changes are useful for all users, or if creating a Chart.js extension would be more appropriate.
- * Please avoid committing in the build Chart.js & Chart.min.js file, as it causes conflicts when merging.
-
-New Chart Types
-===============
-Chart.js is designed to be modular. See http://www.chartjs.org/docs/#advanced-usage-writing-new-chart-types
+Using issues
+------------
-All discussion of new chart types (horizontal bar charts, X-Y scatter plot, etc.) should be done in the Chart.js Google Group at https://groups.google.com/forum/#!forum/chartjs-user-discussion This will get the most exposure for getting people to help define requirements, complete programming and documentation of your vision.
+The [issue tracker](https://github.com/nnnick/Chart.js/issues) is the preferred channel for reporting bugs, requesting new features and submitting pull requests.
-Please do not request new chart types in the project issues. Fully implemented, documented, and useful new charts may be maintained in a new repository. Later, we may add a link to selected external repositories from this project.
+If you're suggesting a new chart type, please take a look at [writing new chart types](https://github.com/nnnick/Chart.js/blob/master/docs/06-Advanced.md#writing-new-chart-types) in the documentation, and some of the [community extensions](https://github.com/nnnick/Chart.js/blob/master/docs/06-Advanced.md#community-extensions) that have been created already.
+
+To keep the library lightweight for everyone, it's unlikely we'll add many more chart types to the core of Chart.js, but issues are a good medium to design and spec out how new chart types could work and look.
+
+Please do not use issues for support requests. For help using Chart.js, please take a look at the [`chartjs`](http://stackoverflow.com/questions/tagged/chartjs) tag on Stack Overflow.
+
+
+Reporting bugs
+--------------
+
+Well structured, detailed bug reports are hugely valuable for the project.
+
+Guidlines for reporting bugs:
+
+ - Check the issue search to see if it has already been reported
+ - Isolate the problem to a simple test case
+ - Provide a demonstration of the problem on [jsbin](http://jsbin.com) or similar
+
+Please provide any additional details associated with the bug, if it's browser of screen density specific, or only happens with a certain configuration or data.
+
+
+Pull requests
+-------------
+
+Clear, concise pull requests are excellent at continuing the projects community driven growth. But please review the guidelines below before starting work on the project.
+
+Guidlines:
+
+ - Please ask before starting significant work on a pull request to check it's a change within the project scope, and isn't a duplicate effort
+ - Please make changes to the files in [`/src`](https://github.com/nnnick/Chart.js/tree/master/src), not `Chart.js` or `Chart.min.js` in the repo root directory
+ - Tabs for indentation, not spaces please.
+ - If adding new functionality, please also update the relevant `.md` file in [`/docs`](https://github.com/nnnick/Chart.js/tree/master/docs)
+ - Please make your commits in logical sections with clear commit messages
+ - Please avoid committing in the build Chart.js & Chart.min.js file, as it may cause conflicts when merging back
+
+
+License
+-------
+
+By contributing your code, you agree to license your contribution under the [MIT license](https://github.com/nnnick/Chart.js/blob/master/LICENSE.md). | false |
Other | chartjs | Chart.js | cfc4599a30e1f49b08abe2133485f8508a896cef.json | Add Travis CI support | .travis.yml | @@ -0,0 +1,17 @@
+language: node_js
+node_js:
+ - "0.11"
+ - "0.10"
+
+before_script:
+ - npm install
+
+script:
+ - gulp jshint
+ - cp Chart.min.js /tmp/OLD
+ - gulp build
+ - cmp Chart.min.js /tmp/OLD # ensure build was run before commit
+
+notifications:
+ email:
+ hello@nickdownie.com | true |
Other | chartjs | Chart.js | cfc4599a30e1f49b08abe2133485f8508a896cef.json | Add Travis CI support | README.md | @@ -1,4 +1,4 @@
-# Chart.js
+# Chart.js [](https://travis-ci.org/nnnick/Chart.js)
[](https://codeclimate.com/github/nnnick/Chart.js)
| true |
Other | chartjs | Chart.js | cfc4599a30e1f49b08abe2133485f8508a896cef.json | Add Travis CI support | gulpfile.js | @@ -6,6 +6,7 @@ var gulp = require('gulp'),
size = require('gulp-size'),
connect = require('gulp-connect'),
replace = require('gulp-replace'),
+ htmlv = require('gulp-html-validator'),
inquirer = require('inquirer'),
semver = require('semver'),
exec = require('child_process').exec,
@@ -90,6 +91,11 @@ gulp.task('jshint', function(){
.pipe(jshint.reporter('default'));
});
+gulp.task('valid', function(){
+ return gulp.src('samples/*.html')
+ .pipe(htmlv());
+});
+
gulp.task('library-size', function(){
return gulp.src('Chart.min.js')
.pipe(size({ | true |
Other | chartjs | Chart.js | cfc4599a30e1f49b08abe2133485f8508a896cef.json | Add Travis CI support | package.json | @@ -18,7 +18,8 @@
"gulp-size": "~0.4.0",
"gulp-uglify": "~0.2.x",
"gulp-util": "~2.2.x",
+ "gulp-html-validator": "^0.0.2",
"inquirer": "^0.5.1",
"semver": "^3.0.1"
}
-}
\ No newline at end of file
+} | true |
Other | chartjs | Chart.js | f81d6f45e19da797def2709551ef2fde2d1c1a1d.json | Update readme about where to put new chart types | README.md | @@ -14,4 +14,4 @@ Chart.js is available under the [MIT license](http://opensource.org/licenses/MIT
When reporting bugs or issues, if you could include a link to a simple [jsbin](http://jsbin.com) or similar demonstrating the issue, that'd be really helpful.
-This project is modular and supports separately-maintained new chart types. This project's scope includes only the chart types included. New chart types will be considered for inclusion in the project if they incude passing build tests and have complete documentation. Please discuss new or "missing" chart types in the [Chart.js User Discussion](https://groups.google.com/forum/#!forum/chartjs-user-discussion) Google Group and not in Issues. For more information, please also see the CONTRIBUTING file.
+This project is modular and supports separately-maintained new chart types. This project's scope includes only the chart types included. New chart types should be created and maintained in separate repositories. We may consider linking to them from this project if they incude passing build tests and have complete documentation. Please discuss new or "missing" chart types in the [Chart.js User Discussion](https://groups.google.com/forum/#!forum/chartjs-user-discussion) Google Group and not in Issues. For more information, please also see the CONTRIBUTING file. | false |
Other | chartjs | Chart.js | 337511110cb139b4f312aa9195aad0629f5ee649.json | Add spm support | package.json | @@ -20,5 +20,8 @@
"gulp-util": "~2.2.x",
"inquirer": "^0.5.1",
"semver": "^3.0.1"
+ },
+ "spm": {
+ "main": "Chart.js"
}
-}
\ No newline at end of file
+} | false |
Other | chartjs | Chart.js | 5ab5e8400afad4ea3e3d3d47531465984f31a2ee.json | add 10 to yLabelWidth on set, rather than on use | src/Chart.Core.js | @@ -1411,7 +1411,7 @@
for (var i=0; i<=this.steps; i++){
this.yLabels.push(template(this.templateString,{value:(this.min + (i * this.stepValue)).toFixed(stepDecimalPlaces)}));
}
- this.yLabelWidth = (this.display && this.showLabels) ? longestText(this.ctx,this.font,this.yLabels) : 0;
+ this.yLabelWidth = (this.display && this.showLabels) ? longestText(this.ctx,this.font,this.yLabels) + 10 : 0;
},
addXLabel : function(label){
this.xLabels.push(label);
@@ -1484,7 +1484,7 @@
this.xScalePaddingRight = lastWidth/2 + 3;
- this.xScalePaddingLeft = (firstWidth/2 > this.yLabelWidth + 10) ? firstWidth/2 : this.yLabelWidth + 10;
+ this.xScalePaddingLeft = (firstWidth/2 > this.yLabelWidth) ? firstWidth/2 : this.yLabelWidth;
this.xLabelRotation = 0;
if (this.display){
@@ -1503,7 +1503,7 @@
lastRotated = cosRotation * lastWidth;
// We're right aligning the text now.
- if (firstRotated + this.fontSize / 2 > this.yLabelWidth + 8){
+ if (firstRotated + this.fontSize / 2 > this.yLabelWidth){
this.xScalePaddingLeft = firstRotated + this.fontSize / 2;
}
this.xScalePaddingRight = this.fontSize/2; | false |
Other | chartjs | Chart.js | 7eabb701300bf64d285ac9a94b2d9769d8ab9767.json | Add strict language to README. | README.md | @@ -13,3 +13,5 @@ Chart.js is available under the [MIT license](http://opensource.org/licenses/MIT
## Bugs & issues
When reporting bugs or issues, if you could include a link to a simple [jsbin](http://jsbin.com) or similar demonstrating the issue, that'd be really helpful.
+
+This project is modular and supports separately-maintained new chart types. This project's scope includes only the chart types included. New chart types will be considered for inclusion in the project if they incude passing build tests and have complete documentation. Please discuss new or "missing" chart types in the [Chart.js User Discussion](https://groups.google.com/forum/#!forum/chartjs-user-discussion) Google Group and not in Issues. For more information, please also see the CONTRIBUTING file. | false |
Other | chartjs | Chart.js | 2ef91b1c783b1f9d415c9bd2f4aba8ba9f958182.json | Use canonical docs url | README.md | @@ -4,7 +4,7 @@
## Documentation
-You can find documentation at [chartjs.org/docs](http://www.chartjs.org/docs). The markdown files that build the site are available under `/docs`. Please note - in some of the json examples of configuration you might notice some liquid tags - this is just for the generating the site html, please disregard.
+You can find documentation at [chartjs.org/docs](http://www.chartjs.org/docs/). The markdown files that build the site are available under `/docs`. Please note - in some of the json examples of configuration you might notice some liquid tags - this is just for the generating the site html, please disregard.
## License
| false |
Other | chartjs | Chart.js | af17a4460ef4a77de663ba45f94c8b65a3646f20.json | Fix old broken links and update for new repo | CONTRIBUTING.md | @@ -7,9 +7,9 @@ Contributions to Chart.js are welcome and encouraged, but please have a look thr
Using issues
------------
-The [issue tracker](https://github.com/nnnick/Chart.js/issues) is the preferred channel for reporting bugs, requesting new features and submitting pull requests.
+The [issue tracker](https://github.com/chartjs/Chart.js/issues) is the preferred channel for reporting bugs, requesting new features and submitting pull requests.
-If you're suggesting a new chart type, please take a look at [writing new chart types](https://github.com/nnnick/Chart.js/blob/master/docs/06-Advanced.md#writing-new-chart-types) in the documentation, and some of the [community extensions](https://github.com/nnnick/Chart.js/blob/master/docs/06-Advanced.md#community-extensions) that have been created already.
+If you're suggesting a new chart type, please take a look at [writing new chart types](https://github.com/chartjs/Chart.js/blob/master/docs/07-Advanced.md#writing-new-chart-types) in the documentation or consider [creating a plugin](https://github.com/chartjs/Chart.js/blob/master/docs/07-Advanced.md#creating-plugins).
To keep the library lightweight for everyone, it's unlikely we'll add many more chart types to the core of Chart.js, but issues are a good medium to design and spec out how new chart types could work and look.
@@ -43,21 +43,22 @@ Clear, concise pull requests are excellent at continuing the project's community
Be advised that **Chart.js 1.0.2 is in feature-complete status**. Pull requests adding new features to the 1.x branch will be disregarded.
-Guidlines:
+Guidelines:
- Please create an issue first:
- For bugs, we can discuss the fixing approach
- For enhancements, we can discuss if it is within the project scope and avoid duplicate effort
- - Please make changes to the files in [`/src`](https://github.com/nnnick/Chart.js/tree/master/src), not `Chart.js` or `Chart.min.js` in the repo root directory, this avoids merge conflicts
+ - Please make changes to the files in [`/src`](https://github.com/chartjs/Chart.js/tree/master/src), not `Chart.js` or `Chart.min.js` in the repo root directory, this avoids merge conflicts
- Tabs for indentation, not spaces please
- - If adding new functionality, please also update the relevant `.md` file in [`/docs`](https://github.com/nnnick/Chart.js/tree/master/docs)
+ - If adding new functionality, please also update the relevant `.md` file in [`/docs`](https://github.com/chartjs/Chart.js/tree/master/docs)
- Please make your commits in logical sections with clear commit messages
Joining the project
-------------
- - Active committers and contributors are invited to introduce yourself and request commit access to this project. Please send an email to hello@nickdownie.com or file an issue.
+ - Active committers and contributors are invited to introduce yourself and request commit access to this project. Please send an email to hello@nickdownie.com or file an issue.
+ - We have a very active Slack community that you can join at https://chartjs-slack-automation.herokuapp.com. If you think you can help, we'd love to have you!
License
-------
-By contributing your code, you agree to license your contribution under the [MIT license](https://github.com/nnnick/Chart.js/blob/master/LICENSE.md).
+By contributing your code, you agree to license your contribution under the [MIT license](https://github.com/chartjs/Chart.js/blob/master/LICENSE.md). | false |
Other | chartjs | Chart.js | 36b9ee7e9eabd0fe7ad5cf5c5db821570a024c24.json | Update coverage badge for switched location | README.md | @@ -1,6 +1,6 @@
# Chart.js
-[](https://travis-ci.org/chartjs/Chart.js) [](https://codeclimate.com/github/nnnick/Chart.js)[](https://coveralls.io/r/nnnick/Chart.js?branch=master)
+[](https://travis-ci.org/chartjs/Chart.js) [](https://codeclimate.com/github/nnnick/Chart.js)[](https://coveralls.io/github/chartjs/Chart.js?branch=master)
[](https://chartjs-slack-automation.herokuapp.com/)
| false |
Other | chartjs | Chart.js | a417e78b8098e9c842039652ee2c0666381eb4f5.json | Remove unnecessary partial sentence | docs/00-Getting-Started.md | @@ -273,5 +273,3 @@ img.onload = function() {
}
```
-
-It is common to spec
\ No newline at end of file | false |
Other | chartjs | Chart.js | 47552152c3e1b53baa51735ea11fec0ef7f4eabd.json | Remove file and fix jshint error | samples/zoom.html | @@ -1,232 +0,0 @@
-<!doctype html>
-<html>
-
-<head>
- <title>Scatter Chart</title>
- <script src="../dist/Chart.bundle.js"></script>
- <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
- <style>
- canvas {
- -moz-user-select: none;
- -webkit-user-select: none;
- -ms-user-select: none;
- }
- </style>
-</head>
-
-<body>
- <div style="width:75%">
- <div>
- <canvas id="canvas"></canvas>
- </div>
- </div>
- <script src="http://hammerjs.github.io/dist/hammer.min.js"></script>
- <script type="text/javascript">
- var helpers = Chart.helpers;
- function canZoomDirection(mode, dir) {
- if (mode === undefined) {
- return true;
- } else if (typeof mode === 'string') {
- return mode.indexOf(dir) !== -1;
- }
-
- return false;
- }
-
- function zoomScaleIn(scale, zoom, center) {
- if (typeof scale.min === 'number' && typeof scale.max === 'number') {
- var newDiff = (scale.max - scale.min) * (zoom - 1);
- scale.options.ticks.min = scale.min + (newDiff / 2);
- scale.options.ticks.max = scale.max - (newDiff / 2);
- } else {
- // Category scale
- var indexDiff = scale.maxIndex - scale.minIndex;
- }
- }
-
- function doZoom(chartInstance, zoom, center) {
- var ca = chartInstance.chartArea;
- if (!center) {
- center = {
- x: (ca.left + ca.right) / 2,
- y: (ca.top + ca.bottom) / 2,
- }
- }
-
- if (chartInstance.options.zoom && chartInstance.options.zoom.enabled) {
- // Do the zoom here
- helpers.each(chartInstance.scales, function(scale, id) {
- if (scale.isHorizontal() && canZoomDirection(chartInstance.options.zoom.mode, 'x')) {
- zoomScaleIn(scale, zoom, center);
- } else if (canZoomDirection(chartInstance.options.zoom.mode, 'y')) {
- // Do Y zoom
- zoomScaleIn(scale, zoom, center);
- }
- });
-
- chartInstance.update();
- }
- }
-
- // Chartjs Zoom Plugin
- var ZoomPlugin = Chart.PluginBase.extend({
- beforeInit: function(chartInstance) {
- var node = chartInstance.chart.ctx.canvas;
- var options = chartInstance.options;
- var wheelHandler = function(e) {
- if (e.wheelDelta > 0) {
- doZoom(chartInstance, 1.1);
- } else {
- doZoom(chartInstance, 0.909);
- }
- };
- chartInstance._wheelHandler = wheelHandler;
-
- node.addEventListener('mousewheel', wheelHandler);
-
- var mc = new window.Hammer.Manager(node);
- mc.add(new Hammer.Pinch());
-
- var handlePinch = function handlePinch(e) {
- var diff = 1 / (currentPinchScaling) * e.scale;
- doZoom(chartInstance, diff, e.center);
-
- // Keep track of overall scale
- currentPinchScaling = e.scale;
- };
-
- // Hammer reports the total scaling. We need the incremental amount
- var currentPinchScaling;
-
- mc.on('pinchstart', function(e) {
- currentPinchScaling = 1; // reset tracker
- });
- mc.on('pinch', handlePinch);
- mc.on('pinchend', function(e) {
- handlePinch(e);
- currentPinchScaling = null; // reset
- });
- },
-
- destroy: function(chartInstance) {
- var node = chartInstance.chart.ctx.canvas;
-
- // Remove wheel handler
- node.removeEventListener('mousewheel', chartInstance._wheelHandler);
- }
- });
-
- Chart.pluginService.register(new ZoomPlugin());
- </script>
-
- <script>
- var randomScalingFactor = function() {
- return (Math.random() > 0.5 ? 1.0 : -1.0) * Math.round(Math.random() * 100);
- };
- var randomColor = function(opacity) {
- return 'rgba(' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + Math.round(Math.random() * 255) + ',' + (opacity || '.3') + ')';
- };
-
- var scatterChartData = {
- datasets: [{
- label: "My First dataset",
- data: [{
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }]
- }, {
- label: "My Second dataset",
- data: [{
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }, {
- x: randomScalingFactor(),
- y: randomScalingFactor(),
- }]
- }]
- };
-
- $.each(scatterChartData.datasets, function(i, dataset) {
- dataset.borderColor = randomColor(0.4);
- dataset.backgroundColor = randomColor(0.1);
- dataset.pointBorderColor = randomColor(0.7);
- dataset.pointBackgroundColor = randomColor(0.5);
- dataset.pointBorderWidth = 1;
- });
-
- window.onload = function() {
- var ctx = document.getElementById("canvas").getContext("2d");
- window.myScatter = Chart.Scatter(ctx, {
- data: scatterChartData,
- options: {
- title: {
- display: true,
- text: 'Chart.js Scatter Chart'
- },
- scales: {
- xAxes: [{
- gridLines: {
- zeroLineColor: "rgba(0,255,0,1)"
- },
- scaleLabel: {
- display: true,
- labelString: 'x axis'
- },
- ticks: {
- maxRotation: 0
- }
- }],
- yAxes: [{
- gridLines: {
- zeroLineColor: "rgba(0,255,0,1)"
- },
- scaleLabel: {
- display: true,
- labelString: 'y axis'
- }
- }]
- },
- zoom: {
- enabled: true,
- mode: 'x'
- }
- }
- });
- };
- </script>
-</body>
-
-</html> | true |
Other | chartjs | Chart.js | 47552152c3e1b53baa51735ea11fec0ef7f4eabd.json | Remove file and fix jshint error | src/core/core.controller.js | @@ -422,7 +422,7 @@ module.exports = function(Chart) {
canvas.style.width = this.chart.originalCanvasStyleWidth;
canvas.style.height = this.chart.originalCanvasStyleHeight;
- Chart.pluginService.notifyPlugins('destory', [this, easingDecimal]);
+ Chart.pluginService.notifyPlugins('destory', [this]);
delete Chart.instances[this.id];
}, | true |
Other | chartjs | Chart.js | 527e7d9b7a5fe198e9cf096890bc30fb6a4bdafc.json | Update colours + example values in docs | docs/02-Line-Chart.md | @@ -37,17 +37,17 @@ var data = {
label: "My First dataset",
// Boolean - if true fill the area under the line
- fill: false,
-
- // Tension - bezier curve tension of the line. Set to 0 to draw straight lines connecting points
- // Used to be called "tension" but was renamed for consistency. The old option name continues to work for compatibility.
- lineTension: 0.1,
+ fill: false,
+
+ // Tension - bezier curve tension of the line. Set to 0 to draw straight lines connecting points
+ // Used to be called "tension" but was renamed for consistency. The old option name continues to work for compatibility.
+ lineTension: 0.1,
// String - the color to fill the area under the line with if fill is true
- backgroundColor: "rgba(220,220,220,0.2)",
+ backgroundColor: "rgba(75,192,192,0.4)",
- // String - Line color
- borderColor: "rgba(220,220,220,1)",
+ // String - Line color
+ borderColor: "rgba(75,192,192,1)",
// String - cap style of the line. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap
borderCapStyle: 'butt',
@@ -59,39 +59,39 @@ var data = {
borderDashOffset: 0.0,
// String - line join style. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin
- borderJoinStyle: 'miter',
-
- // The properties below allow an array to be specified to change the value of the item at the given index
+ borderJoinStyle: 'miter',
+
+ // The properties below allow an array to be specified to change the value of the item at the given index
- // String or Array - Point stroke color
- pointBorderColor: "rgba(220,220,220,1)",
+ // String or Array - Point stroke color
+ pointBorderColor: "rgba(75,192,192,1)",
- // String or Array - Point fill color
+ // String or Array - Point fill color
pointBackgroundColor: "#fff",
- // Number or Array - Stroke width of point border
+ // Number or Array - Stroke width of point border
pointBorderWidth: 1,
- // Number or Array - Radius of point when hovered
+ // Number or Array - Radius of point when hovered
pointHoverRadius: 5,
- // String or Array - point background color when hovered
- pointHoverBackgroundColor: "rgba(220,220,220,1)",
+ // String or Array - point background color when hovered
+ pointHoverBackgroundColor: "rgba(75,192,192,1)",
- // String or Array - Point border color when hovered
+ // String or Array - Point border color when hovered
pointHoverBorderColor: "rgba(220,220,220,1)",
- // Number or Array - border width of point when hovered
- pointHoverBorderWidth: 2,
+ // Number or Array - border width of point when hovered
+ pointHoverBorderWidth: 2,
+
+ // Number or Array - the pixel size of the point shape. Can be set to 0 to not render a circle over the point
+ // Used to be called "radius" but was renamed for consistency. The old option name continues to work for compatibility.
+ pointRadius: 1,
- // Number or Array - the pixel size of the point shape. Can be set to 0 to not render a circle over the point
- // Used to be called "radius" but was renamed for consistency. The old option name continues to work for compatibility.
- pointRadius: 1,
-
- // Number or Array - the pixel size of the non-displayed point that reacts to mouse hover events
- //
- // Used to be called "hitRadius" but was renamed for consistency. The old option name continues to work for compatibility.
- pointHitRadius: 10,
+ // Number or Array - the pixel size of the non-displayed point that reacts to mouse hover events
+ //
+ // Used to be called "hitRadius" but was renamed for consistency. The old option name continues to work for compatibility.
+ pointHitRadius: 10,
// The actual data
data: [65, 59, 80, 81, 56, 55, 40],
@@ -102,14 +102,14 @@ var data = {
{
label: "My Second dataset",
fill: false,
- backgroundColor: "rgba(220,220,220,0.2)",
- borderColor: "rgba(220,220,220,1)",
- pointBorderColor: "rgba(220,220,220,1)",
+ backgroundColor: "rgba(255,205,86,0.4)",
+ borderColor: "rgba(255,205,86,1)",
+ pointBorderColor: "rgba(255,205,86,1)",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
- pointHoverBackgroundColor: "rgba(220,220,220,1)",
- pointHoverBorderColor: "rgba(220,220,220,1)",
+ pointHoverBackgroundColor: "rgba(255,205,86,1)",
+ pointHoverBorderColor: "rgba(255,205,86,1)",
pointHoverBorderWidth: 2,
data: [28, 48, 40, 19, 86, 27, 90]
} | true |
Other | chartjs | Chart.js | 527e7d9b7a5fe198e9cf096890bc30fb6a4bdafc.json | Update colours + example values in docs | docs/03-Bar-Chart.md | @@ -32,19 +32,19 @@ var data = {
// The properties below allow an array to be specified to change the value of the item at the given index
// String or array - the bar color
- backgroundColor: "rgba(220,220,220,0.2)",
+ backgroundColor: "rgba(255,99,132,0.2)",
// String or array - bar stroke color
- borderColor: "rgba(220,220,220,1)",
+ borderColor: "rgba(255,99,132,1)",
// Number or array - bar border width
borderWidth: 1,
// String or array - fill color when hovered
- hoverBackgroundColor: "rgba(220,220,220,0.2)",
+ hoverBackgroundColor: "rgba(255,99,132,0.4)",
// String or array - border color when hovered
- hoverBorderColor: "rgba(220,220,220,1)",
+ hoverBorderColor: "rgba(255,99,132,1)",
// The actual data
data: [65, 59, 80, 81, 56, 55, 40],
@@ -54,11 +54,11 @@ var data = {
},
{
label: "My Second dataset",
- backgroundColor: "rgba(220,220,220,0.2)",
- borderColor: "rgba(220,220,220,1)",
+ backgroundColor: "rgba(54,162,235,0.2)",
+ borderColor: "rgba(54,162,235,1)",
borderWidth: 1,
- hoverBackgroundColor: "rgba(220,220,220,0.2)",
- hoverBorderColor: "rgba(220,220,220,1)",
+ hoverBackgroundColor: "rgba(54,162,235,0.4)",
+ hoverBorderColor: "rgba(54,162,235,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
] | true |
Other | chartjs | Chart.js | 527e7d9b7a5fe198e9cf096890bc30fb6a4bdafc.json | Update colours + example values in docs | docs/04-Radar-Chart.md | @@ -29,22 +29,22 @@ var data = {
datasets: [
{
label: "My First dataset",
- backgroundColor: "rgba(220,220,220,0.2)",
- borderColor: "rgba(220,220,220,1)",
- pointBackgroundColor: "rgba(220,220,220,1)",
+ backgroundColor: "rgba(179,181,198,0.2)",
+ borderColor: "rgba(179,181,198,1)",
+ pointBackgroundColor: "rgba(179,181,198,1)",
pointBorderColor: "#fff",
pointHoverBackgroundColor: "#fff",
- pointHoverBorderColor: "rgba(220,220,220,1)",
+ pointHoverBorderColor: "rgba(179,181,198,1)",
data: [65, 59, 90, 81, 56, 55, 40]
},
{
label: "My Second dataset",
- backgroundColor: "rgba(151,187,205,0.2)",
- borderColor: "rgba(151,187,205,1)",
- pointBackgroundColor: "rgba(151,187,205,1)",
+ backgroundColor: "rgba(255,99,132,0.2)",
+ borderColor: "rgba(255,99,132,1)",
+ pointBackgroundColor: "rgba(255,99,132,1)",
pointBorderColor: "#fff",
pointHoverBackgroundColor: "#fff",
- pointHoverBorderColor: "rgba(151,187,205,1)",
+ pointHoverBorderColor: "rgba(255,99,132,1)",
data: [28, 48, 40, 19, 96, 27, 100]
}
] | true |
Other | chartjs | Chart.js | 527e7d9b7a5fe198e9cf096890bc30fb6a4bdafc.json | Update colours + example values in docs | docs/05-Polar-Area-Chart.md | @@ -27,18 +27,18 @@ new Chart(ctx, {
var data = {
datasets: [{
data: [
- 10,
- 32,
- 53,
- 14,
- 22,
+ 11,
+ 16,
+ 7,
+ 3,
+ 14
],
backgroundColor: [
- "#F7464A",
- "#46BFBD",
- "#FDB45C",
- "#949FB1",
- "#4D5360",
+ "#FF6384",
+ "#4BC0C0",
+ "#FFCE56",
+ "#E7E9ED",
+ "#36A2EB"
],
label: 'My dataset' // for legend
}],
@@ -47,7 +47,7 @@ var data = {
"Green",
"Yellow",
"Grey",
- "Dark Grey"
+ "Blue"
]
};
``` | true |
Other | chartjs | Chart.js | 527e7d9b7a5fe198e9cf096890bc30fb6a4bdafc.json | Update colours + example values in docs | docs/06-Pie-Doughnut-Chart.md | @@ -53,14 +53,14 @@ var data = {
{
data: [300, 50, 100],
backgroundColor: [
- "#F7464A",
- "#46BFBD",
- "#FDB45C"
+ "#FF6384",
+ "#36A2EB",
+ "#FFCE56"
],
hoverBackgroundColor: [
- "#FF5A5E",
- "#5AD3D1",
- "#FFC870"
+ "#FF6384",
+ "#36A2EB",
+ "#FFCE56"
]
}]
}; | true |
Other | chartjs | Chart.js | 900d249646532170a8e1b0f98b2598839ab68a63.json | Fix build to include comment at top of file | gulpfile.js | @@ -7,6 +7,7 @@ var gulp = require('gulp'),
connect = require('gulp-connect'),
replace = require('gulp-replace'),
htmlv = require('gulp-html-validator'),
+ insert = require('gulp-insert'),
inquirer = require('inquirer'),
semver = require('semver'),
exec = require('child_process').exec,
@@ -23,6 +24,16 @@ var srcDir = './src/';
var outDir = './dist/';
var testDir = './test/';
+var header = "/*!\n\
+ * Chart.js\n\
+ * http://chartjs.org/\n\
+ * Version: {{ version }}\n\
+ *\n\
+ * Copyright 2016 Nick Downie\n\
+ * Released under the MIT license\n\
+ * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md\n\
+ */\n";
+
var preTestFiles = [
'./node_modules/moment/min/moment.min.js',
];
@@ -57,6 +68,7 @@ function buildTask() {
var bundled = browserify('./src/chart.js')
.bundle()
.pipe(source('Chart.bundle.js'))
+ .pipe(insert.prepend(header))
.pipe(streamify(replace('{{ version }}', package.version)))
.pipe(gulp.dest(outDir))
.pipe(streamify(uglify({
@@ -69,6 +81,7 @@ function buildTask() {
.ignore('moment')
.bundle()
.pipe(source('Chart.js'))
+ .pipe(insert.prepend(header))
.pipe(streamify(replace('{{ version }}', package.version)))
.pipe(gulp.dest(outDir))
.pipe(streamify(uglify({ | true |
Other | chartjs | Chart.js | 900d249646532170a8e1b0f98b2598839ab68a63.json | Fix build to include comment at top of file | package.json | @@ -16,6 +16,7 @@
"gulp-concat": "~2.1.x",
"gulp-connect": "~2.0.5",
"gulp-html-validator": "^0.0.2",
+ "gulp-insert": "~0.5.0",
"gulp-jshint": "~1.5.1",
"gulp-karma": "0.0.4",
"gulp-replace": "^0.4.0", | true |
Other | chartjs | Chart.js | 900d249646532170a8e1b0f98b2598839ab68a63.json | Fix build to include comment at top of file | src/chart.js | @@ -1,14 +1,3 @@
-/*!
- * Chart.js
- * http://chartjs.org/
- * Version: {{ version }}
- *
- * Copyright 2015 Nick Downie
- * Released under the MIT license
- * https://github.com/nnnick/Chart.js/blob/master/LICENSE.md
- */
-
-
var Chart = require('./core/core.js')();
require('./core/core.helpers')(Chart); | true |
Other | chartjs | Chart.js | 58563fddf9eb719f8a6ffc604048a068b305f8a8.json | Fix typo in plugin 'destroy' | src/core/core.controller.js | @@ -422,7 +422,7 @@ module.exports = function(Chart) {
canvas.style.width = this.chart.originalCanvasStyleWidth;
canvas.style.height = this.chart.originalCanvasStyleHeight;
- Chart.pluginService.notifyPlugins('destory', [this]);
+ Chart.pluginService.notifyPlugins('destroy', [this]);
delete Chart.instances[this.id];
}, | true |
Other | chartjs | Chart.js | 58563fddf9eb719f8a6ffc604048a068b305f8a8.json | Fix typo in plugin 'destroy' | src/core/core.plugin.js | @@ -53,6 +53,6 @@ module.exports = function(Chart) {
afterDraw: helpers.noop,
// Called during destroy
- destory: helpers.noop,
+ destroy: helpers.noop,
});
-};
\ No newline at end of file
+}; | true |
Other | chartjs | Chart.js | b21d1476085851aa1be870d11d6217c9e87fdfbc.json | Update the docs | docs/02-Line-Chart.md | @@ -37,14 +37,16 @@ var data = {
label: "My First dataset",
// Boolean - if true fill the area under the line
- fill: false,
+ fill: false,
+
+ // Tension - bezier curve tension of the line. Set to 0 to draw straight lines connecting points
+ // Used to be called "tension" but was renamed for consistency. The old option name continues to work for compatibility.
+ lineTension: 0.1,
// String - the color to fill the area under the line with if fill is true
- backgroundColor: "rgba(220,220,220,0.2)",
-
- // The properties below allow an array to be specified to change the value of the item at the given index
+ backgroundColor: "rgba(220,220,220,0.2)",
- // String or array - Line color
+ // String - Line color
borderColor: "rgba(220,220,220,1)",
// String - cap style of the line. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap
@@ -57,35 +59,39 @@ var data = {
borderDashOffset: 0.0,
// String - line join style. See https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin
- borderJoinStyle: 'miter',
+ borderJoinStyle: 'miter',
+
+ // The properties below allow an array to be specified to change the value of the item at the given index
- // String or array - Point stroke color
+ // String or Array - Point stroke color
pointBorderColor: "rgba(220,220,220,1)",
- // String or array - Point fill color
+ // String or Array - Point fill color
pointBackgroundColor: "#fff",
- // Number or array - Stroke width of point border
+ // Number or Array - Stroke width of point border
pointBorderWidth: 1,
- // Number or array - Radius of point when hovered
+ // Number or Array - Radius of point when hovered
pointHoverRadius: 5,
- // String or array - point background color when hovered
+ // String or Array - point background color when hovered
pointHoverBackgroundColor: "rgba(220,220,220,1)",
- // Point border color when hovered
+ // String or Array - Point border color when hovered
pointHoverBorderColor: "rgba(220,220,220,1)",
- // Number or array - border width of point when hovered
- pointHoverBorderWidth: 2,
-
- // Tension - bezier curve tension of the line. Set to 0 to draw straight lines connecting points
- // Used to be called "tension" but was renamed for consistency. The old option name continues to work for compatibility.
- lineTension: 0.1,
-
- // Number - the pixel size of the point shape. Can be set to 0 to not render a circle over the point
- radius: 1,
+ // Number or Array - border width of point when hovered
+ pointHoverBorderWidth: 2,
+
+ // Number or Array - the pixel size of the point shape. Can be set to 0 to not render a circle over the point
+ // Used to be called "radius" but was renamed for consistency. The old option name continues to work for compatibility.
+ pointRadius: 1,
+
+ // Number or Array - the pixel size of the non-displayed point that reacts to mouse hover events
+ //
+ // Used to be called "hitRadius" but was renamed for consistency. The old option name continues to work for compatibility.
+ pointHitRadius: 10,
// The actual data
data: [65, 59, 80, 81, 56, 55, 40], | false |
Other | chartjs | Chart.js | 76b3494a0ae4d889f98e1af3ac77b4a8cbfab84c.json | Fix build and update to latest node js version. | .travis.yml | @@ -1,7 +1,6 @@
language: node_js
node_js:
- - "5.6"
- - "4.3"
+ - "5.10"
before_install:
- "export CHROME_BIN=/usr/bin/google-chrome" | true |
Other | chartjs | Chart.js | 76b3494a0ae4d889f98e1af3ac77b4a8cbfab84c.json | Fix build and update to latest node js version. | src/core/core.controller.js | @@ -422,7 +422,7 @@ module.exports = function(Chart) {
canvas.style.width = this.chart.originalCanvasStyleWidth;
canvas.style.height = this.chart.originalCanvasStyleHeight;
- Chart.pluginService.notifyPlugins('destory', [this, easingDecimal]);
+ Chart.pluginService.notifyPlugins('destory', [this]);
delete Chart.instances[this.id];
}, | true |
Other | chartjs | Chart.js | 4d4271e6c4088913f3fcbe1e2c8c43d967b3379e.json | Update the docs | docs/02-Line-Chart.md | @@ -80,8 +80,9 @@ var data = {
// Number or array - border width of point when hovered
pointHoverBorderWidth: 2,
- // Tension - bezier curve tension of the line. Set to 0 to draw straight Wlines connecting points
- tension: 0.1,
+ // Tension - bezier curve tension of the line. Set to 0 to draw straight lines connecting points
+ // Used to be called "tension" but was renamed for consistency. The old option name continues to work for compatibility.
+ lineTension: 0.1,
// Number - the pixel size of the point shape. Can be set to 0 to not render a circle over the point
radius: 1, | false |
Other | chartjs | Chart.js | 5fdc0f71af828b8582dfeed4fff0574f079a93df.json | Use UDM build for reproducible sample (#10919) | .github/ISSUE_TEMPLATE/bug.yml | @@ -10,7 +10,7 @@ body:
- type: markdown
attributes:
- value: "Bug reports MUST be submitted with an interactive example: https://codepen.io/pen?template=BapRepQ."
+ value: "Bug reports MUST be submitted with an interactive example: https://codepen.io/leelenaleee/pen/WNyJXEe."
- type: markdown
attributes:
@@ -35,7 +35,7 @@ body:
label: Reproducible sample
description: |
Please provide issue reproduction.
- You can use [this codepen](https://codepen.io/pen?template=BapRepQ) to make a reproducible sample.
+ You can use [this codepen](https://codepen.io/leelenaleee/pen/WNyJXEe) to make a reproducible sample.
Major framework wrappers for chart.js templates:
[vue-chart-3 sandbox (Vue)](https://codesandbox.io/s/vue-chart-3-chart-js-issue-template-bpg7k?file=/src/App.vue) | false |
Other | chartjs | Chart.js | 80a931ebd3299387e4fdb9b2a80ec2139477fbfc.json | docs: add info about ESM into migration guide. (#10903) | docs/migration/v4-migration.md | @@ -37,6 +37,13 @@ A number of changes were made to the configuration options passed to the `Chart`
* The order of the `ChartMeta` parameters have been changed from `<Element, DatasetElement, Type>` to `<Type, Element, DatasetElement>`.
### General
+* Chart.js becomes an [ESM-only package](https://nodejs.org/api/esm.html) ([the UMD bundle is still available](../getting-started/installation.md#cdn)). To use Chart.js, your project should also be an ES module. Make sure to have this in your `package.json`:
+ ```json
+ {
+ "type": "module"
+ }
+ ```
+ If you are experiencing problems with [Jest](https://jestjs.io), follow its [documentation](https://jestjs.io/docs/ecmascript-modules) to enable the ESM support. Or, we can recommend you migrating to [Vitest](https://vitest.dev/). Vitest has the ESM support out of the box and [almost the same API as Jest](https://vitest.dev/guide/migration.html#migrating-from-jest). See an [example of migration](https://github.com/reactchartjs/react-chartjs-2/commit/7f3ec96101d21e43cae8cbfe5e09a46a17cff1ef).
* Removed fallback to `fontColor` for the legend text and strikethrough color.
* Removed `config._chart` fallback for `this.chart` in the filler plugin.
* Removed `this._chart` in the filler plugin. | false |
Other | chartjs | Chart.js | 784216130af7c1a15ad45774d54b34bc090b86d7.json | Add stepSize option to time scale options types (#10910) | types/index.d.ts | @@ -3250,6 +3250,11 @@ export type TimeScaleOptions = Omit<CartesianScaleOptions, 'min' | 'max'> & {
* @default 'auto'
*/
source: 'labels' | 'auto' | 'data';
+ /**
+ * The number of units between grid lines.
+ * @default 1
+ */
+ stepSize: number;
};
};
| true |
Other | chartjs | Chart.js | 784216130af7c1a15ad45774d54b34bc090b86d7.json | Add stepSize option to time scale options types (#10910) | types/tests/scales/options.ts | @@ -17,6 +17,9 @@ const chart = new Chart('test', {
type: 'time',
time: {
unit: 'year'
+ },
+ ticks: {
+ stepSzie: 1
}
},
x1: { | true |
Other | chartjs | Chart.js | 934c14069f4e15b81e38a711a753f6f46281b313.json | update migration guide (#10885) | docs/migration/v4-migration.md | @@ -29,6 +29,9 @@ A number of changes were made to the configuration options passed to the `Chart`
* `maintainAspectRatio` respects container height.
* Time and timeseries scales use `ticks.stepSize` instead of `time.stepSize`, which has been removed.
* `maxTickslimit` wont be used for the ticks in `autoSkip` if the determined max ticks is less then the `maxTicksLimit`.
+* `dist/chart.js` has been removed.
+* `dist/chart.min.js` has been renamed to `dist/chart.umd.js`.
+* `dist/chart.esm.js` has been renamed to `dist/chart.js`.
#### Type changes
* The order of the `ChartMeta` parameters have been changed from `<Element, DatasetElement, Type>` to `<Type, Element, DatasetElement>`. | false |
Other | chartjs | Chart.js | 909c719331d36c5ef4a8871fc62de83f854bfb92.json | Move border opts to correct location for samples (#10884) | docs/axes/cartesian/index.md | @@ -44,8 +44,8 @@ const config = {
options: {
scales: {
x: {
- grid: {
- borderColor: 'red'
+ border: {
+ color: 'red'
}
}
} | true |
Other | chartjs | Chart.js | 909c719331d36c5ef4a8871fc62de83f854bfb92.json | Move border opts to correct location for samples (#10884) | docs/samples/scales/stacked.md | @@ -45,8 +45,8 @@ const config = {
position: 'left',
stack: 'demo',
stackWeight: 2,
- grid: {
- borderColor: Utils.CHART_COLORS.red
+ border: {
+ color: Utils.CHART_COLORS.red
}
},
y2: {
@@ -56,8 +56,8 @@ const config = {
position: 'left',
stack: 'demo',
stackWeight: 1,
- grid: {
- borderColor: Utils.CHART_COLORS.blue
+ border: {
+ color: Utils.CHART_COLORS.blue
}
}
} | true |
Other | chartjs | Chart.js | c0fe7f9b0535b284c064ca964d42e573a2fd9f99.json | Remove V3 support, update readme (#10872) | .github/ISSUE_TEMPLATE/bug.yml | @@ -14,7 +14,7 @@ body:
- type: markdown
attributes:
- value: Chart.js versions lower then 3.x are NOT supported anymore, new issues will be disregarded.
+ value: Chart.js versions lower then 4.x are NOT supported anymore, new issues will be disregarded.
- type: textarea
attributes: | true |
Other | chartjs | Chart.js | c0fe7f9b0535b284c064ca964d42e573a2fd9f99.json | Remove V3 support, update readme (#10872) | .github/release-drafter.yml | @@ -44,7 +44,7 @@ template: |
# Essential Links
* [npm](https://www.npmjs.com/package/chart.js)
- * [Migration guide](https://www.chartjs.org/docs/latest/getting-started/v3-migration)
+ * [Migration guide](https://www.chartjs.org/docs/latest/migration/v4-migration.html)
* [Docs](https://www.chartjs.org/docs/latest/)
* [API](https://www.chartjs.org/docs/latest/api/)
* [Samples](https://www.chartjs.org/docs/latest/samples/) | true |
Other | chartjs | Chart.js | c0fe7f9b0535b284c064ca964d42e573a2fd9f99.json | Remove V3 support, update readme (#10872) | README.md | @@ -15,7 +15,7 @@
## Documentation
-All the links point to the new version 3 of the lib.
+All the links point to the new version 4 of the lib.
* [Introduction](https://www.chartjs.org/docs/latest/)
* [Getting Started](https://www.chartjs.org/docs/latest/getting-started/index)
@@ -27,7 +27,7 @@ All the links point to the new version 3 of the lib.
* [Popular Extensions](https://github.com/chartjs/awesome)
* [Samples](https://www.chartjs.org/samples/)
-In case you are looking for the docs of version 2, you will have to specify the specific version in the url like this: [https://www.chartjs.org/docs/2.9.4/](https://www.chartjs.org/docs/2.9.4/)
+In case you are looking for an older version of the docs, you will have to specify the specific version in the url like this: [https://www.chartjs.org/docs/2.9.4/](https://www.chartjs.org/docs/2.9.4/)
## Contributing
| true |
Other | chartjs | Chart.js | 005aa45c32ca3bf48e0acc8d36c43ccc97507380.json | Fix broken links (#10812) | docs/samples/area/line-stacked.md | @@ -173,7 +173,7 @@ module.exports = {
## Docs
* [Area](../../charts/area.html)
- * [Filling modes](../../charts/area.htmll#filling-modes)
+ * [Filling modes](../../charts/area.html#filling-modes)
* [Line](../../charts/line.html)
* [Data structures (`labels`)](../../general/data-structures.html)
* [Axes scales](../../axes/) | true |
Other | chartjs | Chart.js | 005aa45c32ca3bf48e0acc8d36c43ccc97507380.json | Fix broken links (#10812) | docs/samples/area/radar.md | @@ -142,7 +142,7 @@ module.exports = {
## Docs
* [Area](../../charts/area.html)
- * [Filling modes](../../charts/area.htmll#filling-modes)
+ * [Filling modes](../../charts/area.html#filling-modes)
* [`propagate`](../../charts/area.html#propagate)
* [Radar](../../charts/radar.html)
* [Data structures (`labels`)](../../general/data-structures.html) | true |
Other | chartjs | Chart.js | c338942ebb113a4d46b734db86aff7ffdb296e19.json | Convert the Arc element to TS (#10772)
* Convert the Arc element to TS
* Make max-statements and complexity warnings in TS files as well
* Increase size limit
* Update src/elements/element.arc.ts
Co-authored-by: Dan Onoshko <danon0404@gmail.com>
Co-authored-by: Dan Onoshko <danon0404@gmail.com> | .eslintrc.yml | @@ -47,6 +47,8 @@ overrides:
- plugin:@typescript-eslint/recommended
rules:
+ complexity: ["warn", 10]
+ max-statements: ["warn", 30]
# Replace stock eslint rules with typescript-eslint equivalents for proper
# TypeScript support.
indent: "off" | true |
Other | chartjs | Chart.js | c338942ebb113a4d46b734db86aff7ffdb296e19.json | Convert the Arc element to TS (#10772)
* Convert the Arc element to TS
* Make max-statements and complexity warnings in TS files as well
* Increase size limit
* Update src/elements/element.arc.ts
Co-authored-by: Dan Onoshko <danon0404@gmail.com>
Co-authored-by: Dan Onoshko <danon0404@gmail.com> | .size-limit.cjs | @@ -7,7 +7,7 @@ function modifyWebpackConfig(config) {
module.exports = [
{
path: 'dist/chart.js',
- limit: '77.5 KB',
+ limit: '78.5 KB',
webpack: false,
running: false
}, | true |
Other | chartjs | Chart.js | c338942ebb113a4d46b734db86aff7ffdb296e19.json | Convert the Arc element to TS (#10772)
* Convert the Arc element to TS
* Make max-statements and complexity warnings in TS files as well
* Increase size limit
* Update src/elements/element.arc.ts
Co-authored-by: Dan Onoshko <danon0404@gmail.com>
Co-authored-by: Dan Onoshko <danon0404@gmail.com> | src/elements/element.arc.ts | @@ -2,11 +2,10 @@ import Element from '../core/core.element';
import {_angleBetween, getAngleFromPoint, TAU, HALF_PI, valueOrDefault} from '../helpers/index';
import {PI, _isBetween, _limitValue} from '../helpers/helpers.math';
import {_readValueToProps} from '../helpers/helpers.options';
+import type {ArcOptions, Point} from '../../types';
-/** @typedef {{ x: number, y: number, startAngle: number, endAngle: number, innerRadius: number, outerRadius: number, circumference: number }} ArcProps */
-/** @typedef {import('../../types/geometric').Point} Point */
-function clipArc(ctx, element, endAngle) {
+function clipArc(ctx: CanvasRenderingContext2D, element: ArcElement, endAngle: number) {
const {startAngle, pixelMargin, x, y, outerRadius, innerRadius} = element;
let angleMargin = pixelMargin / outerRadius;
@@ -30,13 +29,8 @@ function toRadiusCorners(value) {
/**
* Parse border radius from the provided options
- * @param {ArcElement} arc
- * @param {number} innerRadius
- * @param {number} outerRadius
- * @param {number} angleDelta Arc circumference in radians
- * @returns
*/
-function parseBorderRadius(arc, innerRadius, outerRadius, angleDelta) {
+function parseBorderRadius(arc: ArcElement, innerRadius: number, outerRadius: number, angleDelta: number) {
const o = toRadiusCorners(arc.options.borderRadius);
const halfThickness = (outerRadius - innerRadius) / 2;
const innerLimit = Math.min(halfThickness, angleDelta * innerRadius / 2);
@@ -63,13 +57,8 @@ function parseBorderRadius(arc, innerRadius, outerRadius, angleDelta) {
/**
* Convert (r, 𝜃) to (x, y)
- * @param {number} r Radius from center point
- * @param {number} theta Angle in radians
- * @param {number} x Center X coordinate
- * @param {number} y Center Y coordinate
- * @returns {{ x: number; y: number }} Rectangular coordinate point
*/
-function rThetaToXY(r, theta, x, y) {
+function rThetaToXY(r: number, theta: number, x: number, y: number) {
return {
x: x + r * Math.cos(theta),
y: y + r * Math.sin(theta),
@@ -93,10 +82,15 @@ function rThetaToXY(r, theta, x, y) {
* 7 4
* \ /
* 6---------5 Inner
- * @param {CanvasRenderingContext2D} ctx
- * @param {ArcElement} element
*/
-function pathArc(ctx, element, offset, spacing, end, circular) {
+function pathArc(
+ ctx: CanvasRenderingContext2D,
+ element: ArcElement,
+ offset: number,
+ spacing: number,
+ end: number,
+ circular: boolean,
+) {
const {x, y, startAngle: start, pixelMargin, innerRadius: innerR} = element;
const outerRadius = Math.max(element.outerRadius + spacing + offset - pixelMargin, 0);
@@ -187,7 +181,13 @@ function pathArc(ctx, element, offset, spacing, end, circular) {
ctx.closePath();
}
-function drawArc(ctx, element, offset, spacing, circular) {
+function drawArc(
+ ctx: CanvasRenderingContext2D,
+ element: ArcElement,
+ offset: number,
+ spacing: number,
+ circular: boolean,
+) {
const {fullCircles, startAngle, circumference} = element;
let endAngle = element.endAngle;
if (fullCircles) {
@@ -209,7 +209,7 @@ function drawArc(ctx, element, offset, spacing, circular) {
return endAngle;
}
-function drawFullCircleBorders(ctx, element, inner) {
+function drawFullCircleBorders(ctx: CanvasRenderingContext2D, element: ArcElement, inner: boolean) {
const {x, y, startAngle, pixelMargin, fullCircles} = element;
const outerRadius = Math.max(element.outerRadius - pixelMargin, 0);
const innerRadius = element.innerRadius + pixelMargin;
@@ -233,7 +233,14 @@ function drawFullCircleBorders(ctx, element, inner) {
}
}
-function drawBorder(ctx, element, offset, spacing, endAngle, circular) {
+function drawBorder(
+ ctx: CanvasRenderingContext2D,
+ element: ArcElement,
+ offset: number,
+ spacing: number,
+ endAngle: number,
+ circular: boolean,
+) {
const {options} = element;
const {borderWidth, borderJoinStyle} = options;
const inner = options.borderAlign === 'inner';
@@ -262,13 +269,18 @@ function drawBorder(ctx, element, offset, spacing, endAngle, circular) {
ctx.stroke();
}
-export default class ArcElement extends Element {
+export interface ArcProps extends Point {
+ startAngle: number;
+ endAngle: number;
+ innerRadius: number;
+ outerRadius: number;
+ circumference: number;
+}
+
+export default class ArcElement extends Element<ArcProps, ArcOptions> {
static id = 'arc';
- /**
- * @type {any}
- */
static defaults = {
borderAlign: 'center',
borderColor: '#fff',
@@ -281,13 +293,18 @@ export default class ArcElement extends Element {
circular: true,
};
- /**
- * @type {any}
- */
static defaultRoutes = {
backgroundColor: 'backgroundColor'
};
+ circumference: number;
+ endAngle: number;
+ fullCircles: number;
+ innerRadius: number;
+ outerRadius: number;
+ pixelMargin: number;
+ startAngle: number;
+
constructor(cfg) {
super();
@@ -305,22 +322,16 @@ export default class ArcElement extends Element {
}
}
- /**
- * @param {number} chartX
- * @param {number} chartY
- * @param {boolean} [useFinalPosition]
- */
- inRange(chartX, chartY, useFinalPosition) {
- // @ts-ignore This will be fixed when the arc element is converted to TS
- const point = /** @type {Point} */ (this.getProps(['x', 'y'], useFinalPosition));
+ inRange(chartX: number, chartY: number, useFinalPosition: boolean) {
+ const point = this.getProps(['x', 'y'], useFinalPosition);
const {angle, distance} = getAngleFromPoint(point, {x: chartX, y: chartY});
- const {startAngle, endAngle, innerRadius, outerRadius, circumference} = /** @type {ArcProps} */ (this.getProps([
+ const {startAngle, endAngle, innerRadius, outerRadius, circumference} = this.getProps([
'startAngle',
'endAngle',
'innerRadius',
'outerRadius',
'circumference'
- ], useFinalPosition));
+ ], useFinalPosition);
const rAdjust = this.options.spacing / 2;
const _circumference = valueOrDefault(circumference, endAngle - startAngle);
const betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle);
@@ -329,19 +340,16 @@ export default class ArcElement extends Element {
return (betweenAngles && withinRadius);
}
- /**
- * @param {boolean} [useFinalPosition]
- */
- getCenterPoint(useFinalPosition) {
- const {x, y, startAngle, endAngle, innerRadius, outerRadius} = /** @type {ArcProps} */ (this.getProps([
+ getCenterPoint(useFinalPosition: boolean) {
+ const {x, y, startAngle, endAngle, innerRadius, outerRadius} = this.getProps([
'x',
'y',
'startAngle',
'endAngle',
'innerRadius',
'outerRadius',
'circumference',
- ], useFinalPosition));
+ ], useFinalPosition);
const {offset, spacing} = this.options;
const halfAngle = (startAngle + endAngle) / 2;
const halfRadius = (innerRadius + outerRadius + spacing + offset) / 2;
@@ -351,14 +359,11 @@ export default class ArcElement extends Element {
};
}
- /**
- * @param {boolean} [useFinalPosition]
- */
- tooltipPosition(useFinalPosition) {
+ tooltipPosition(useFinalPosition: boolean) {
return this.getCenterPoint(useFinalPosition);
}
- draw(ctx) {
+ draw(ctx: CanvasRenderingContext2D) {
const {options, circumference} = this;
const offset = (options.offset || 0) / 4;
const spacing = (options.spacing || 0) / 2; | true |
Other | chartjs | Chart.js | c338942ebb113a4d46b734db86aff7ffdb296e19.json | Convert the Arc element to TS (#10772)
* Convert the Arc element to TS
* Make max-statements and complexity warnings in TS files as well
* Increase size limit
* Update src/elements/element.arc.ts
Co-authored-by: Dan Onoshko <danon0404@gmail.com>
Co-authored-by: Dan Onoshko <danon0404@gmail.com> | types/index.d.ts | @@ -1,6 +1,7 @@
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils';
import { TimeUnit } from '../src/core/core.adapters';
+import ArcElement from '../src/elements/element.arc';
import PointElement from '../src/elements/element.point';
import { EasingFunction } from '../src/helpers/helpers.easing';
import { AnimationEvent } from './animation';
@@ -11,6 +12,7 @@ import { ChartArea, Padding, Point } from './geometric';
import { LayoutItem, LayoutPosition } from './layout';
export { EasingFunction } from '../src/helpers/helpers.easing';
+export { default as ArcElement, ArcProps } from '../src/elements/element.arc';
export { default as PointElement, PointProps } from '../src/elements/element.point';
export { Animation, Animations, Animator, AnimationEvent } from './animation';
export { Color } from './color';
@@ -1676,14 +1678,6 @@ export interface Segment {
loop: boolean;
}
-export interface ArcProps extends Point {
- startAngle: number;
- endAngle: number;
- innerRadius: number;
- outerRadius: number;
- circumference: number;
-}
-
export interface ArcBorderRadius {
outerStart: number;
outerEnd: number;
@@ -1718,21 +1712,17 @@ export interface ArcOptions extends CommonElementOptions {
* @default true
*/
circular: boolean;
+
+ /**
+ * Spacing between arcs
+ */
+ spacing: number
}
export interface ArcHoverOptions extends CommonHoverOptions {
hoverOffset: number;
}
-export interface ArcElement<T extends ArcProps = ArcProps, O extends ArcOptions = ArcOptions>
- extends Element<T, O>,
- VisualElement {}
-
-export declare const ArcElement: ChartComponent & {
- prototype: ArcElement;
- new (cfg: AnyObject): ArcElement;
-};
-
export interface LineProps {
points: Point[]
} | true |
Other | chartjs | Chart.js | 41612d1320db0fcdd08da9cab550ca2deb3a418f.json | Convert the curve helpers to TS (#10733)
* Convert the curve helpers to TS
* Remove old type | src/helpers/helpers.curve.ts | @@ -1,11 +1,35 @@
import {almostEquals, distanceBetweenPoints, sign} from './helpers.math';
import {_isPointInArea} from './helpers.canvas';
+import {ChartArea} from '../../types';
+
+export interface SplinePoint {
+ x: number;
+ y: number;
+ skip?: boolean;
+
+ // Both Bezier and monotone interpolations have these fields
+ // but they are added in different spots
+ cp1x?: number;
+ cp1y?: number;
+ cp2x?: number;
+ cp2y?: number;
+}
const EPSILON = Number.EPSILON || 1e-14;
-const getPoint = (points, i) => i < points.length && !points[i].skip && points[i];
-const getValueAxis = (indexAxis) => indexAxis === 'x' ? 'y' : 'x';
-export function splineCurve(firstPoint, middlePoint, afterPoint, t) {
+type OptionalSplinePoint = SplinePoint | false
+const getPoint = (points: SplinePoint[], i: number): OptionalSplinePoint => i < points.length && !points[i].skip && points[i];
+const getValueAxis = (indexAxis: 'x' | 'y') => indexAxis === 'x' ? 'y' : 'x';
+
+export function splineCurve(
+ firstPoint: SplinePoint,
+ middlePoint: SplinePoint,
+ afterPoint: SplinePoint,
+ t: number
+): {
+ previous: SplinePoint
+ next: SplinePoint
+ } {
// Props to Rob Spencer at scaled innovation for his post on splining between points
// http://scaledinnovation.com/analytics/splines/aboutSplines.html
@@ -42,10 +66,10 @@ export function splineCurve(firstPoint, middlePoint, afterPoint, t) {
/**
* Adjust tangents to ensure monotonic properties
*/
-function monotoneAdjust(points, deltaK, mK) {
+function monotoneAdjust(points: SplinePoint[], deltaK: number[], mK: number[]) {
const pointsLen = points.length;
- let alphaK, betaK, tauK, squaredMagnitude, pointCurrent;
+ let alphaK: number, betaK: number, tauK: number, squaredMagnitude: number, pointCurrent: OptionalSplinePoint;
let pointAfter = getPoint(points, 0);
for (let i = 0; i < pointsLen - 1; ++i) {
pointCurrent = pointAfter;
@@ -72,10 +96,10 @@ function monotoneAdjust(points, deltaK, mK) {
}
}
-function monotoneCompute(points, mK, indexAxis = 'x') {
+function monotoneCompute(points: SplinePoint[], mK: number[], indexAxis: 'x' | 'y' = 'x') {
const valueAxis = getValueAxis(indexAxis);
const pointsLen = points.length;
- let delta, pointBefore, pointCurrent;
+ let delta: number, pointBefore: OptionalSplinePoint, pointCurrent: OptionalSplinePoint;
let pointAfter = getPoint(points, 0);
for (let i = 0; i < pointsLen; ++i) {
@@ -106,26 +130,15 @@ function monotoneCompute(points, mK, indexAxis = 'x') {
* but preserves monotonicity of the provided data and ensures no local extremums are added
* between the dataset discrete points due to the interpolation.
* See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
- *
- * @param {{
- * x: number,
- * y: number,
- * skip?: boolean,
- * cp1x?: number,
- * cp1y?: number,
- * cp2x?: number,
- * cp2y?: number,
- * }[]} points
- * @param {string} indexAxis
*/
-export function splineCurveMonotone(points, indexAxis = 'x') {
+export function splineCurveMonotone(points: SplinePoint[], indexAxis: 'x' | 'y' = 'x') {
const valueAxis = getValueAxis(indexAxis);
const pointsLen = points.length;
- const deltaK = Array(pointsLen).fill(0);
- const mK = Array(pointsLen);
+ const deltaK: number[] = Array(pointsLen).fill(0);
+ const mK: number[] = Array(pointsLen);
// Calculate slopes (deltaK) and initialize tangents (mK)
- let i, pointBefore, pointCurrent;
+ let i, pointBefore: OptionalSplinePoint, pointCurrent: OptionalSplinePoint;
let pointAfter = getPoint(points, 0);
for (i = 0; i < pointsLen; ++i) {
@@ -144,20 +157,20 @@ export function splineCurveMonotone(points, indexAxis = 'x') {
}
mK[i] = !pointBefore ? deltaK[i]
: !pointAfter ? deltaK[i - 1]
- : (sign(deltaK[i - 1]) !== sign(deltaK[i])) ? 0
- : (deltaK[i - 1] + deltaK[i]) / 2;
+ : (sign(deltaK[i - 1]) !== sign(deltaK[i])) ? 0
+ : (deltaK[i - 1] + deltaK[i]) / 2;
}
monotoneAdjust(points, deltaK, mK);
monotoneCompute(points, mK, indexAxis);
}
-function capControlPoint(pt, min, max) {
+function capControlPoint(pt: number, min: number, max: number) {
return Math.max(Math.min(pt, max), min);
}
-function capBezierPoints(points, area) {
+function capBezierPoints(points: SplinePoint[], area: ChartArea) {
let i, ilen, point, inArea, inAreaPrev;
let inAreaNext = _isPointInArea(points[0], area);
for (i = 0, ilen = points.length; i < ilen; ++i) {
@@ -182,8 +195,14 @@ function capBezierPoints(points, area) {
/**
* @private
*/
-export function _updateBezierControlPoints(points, options, area, loop, indexAxis) {
- let i, ilen, point, controlPoints;
+export function _updateBezierControlPoints(
+ points: SplinePoint[],
+ options,
+ area: ChartArea,
+ loop: boolean,
+ indexAxis: 'x' | 'y'
+) {
+ let i: number, ilen: number, point: SplinePoint, controlPoints: ReturnType<typeof splineCurve>;
// Only consider points that are drawn in case the spanGaps option is used
if (options.spanGaps) { | true |
Other | chartjs | Chart.js | 41612d1320db0fcdd08da9cab550ca2deb3a418f.json | Convert the curve helpers to TS (#10733)
* Convert the curve helpers to TS
* Remove old type | src/helpers/helpers.interpolation.ts | @@ -1,5 +1,5 @@
import type {Point} from '../../types/geometric';
-import type {MonotoneSplinePoint} from '../../types/helpers';
+import type {SplinePoint} from './helpers.curve';
/**
* @private
@@ -30,7 +30,7 @@ export function _steppedInterpolation(
/**
* @private
*/
-export function _bezierInterpolation(p1: MonotoneSplinePoint, p2: MonotoneSplinePoint, t: number, mode?) { // eslint-disable-line @typescript-eslint/no-unused-vars
+export function _bezierInterpolation(p1: SplinePoint, p2: SplinePoint, t: number, mode?) { // eslint-disable-line @typescript-eslint/no-unused-vars
const cp1 = {x: p1.cp2x, y: p1.cp2y};
const cp2 = {x: p2.cp1x, y: p2.cp1y};
const a = _pointInLine(p1, cp1, t); | true |
Other | chartjs | Chart.js | 41612d1320db0fcdd08da9cab550ca2deb3a418f.json | Convert the curve helpers to TS (#10733)
* Convert the curve helpers to TS
* Remove old type | src/helpers/types.ts | @@ -7,6 +7,7 @@
export * from './helpers.color';
export * from './helpers.collection';
export * from './helpers.core';
+export * from './helpers.curve';
export * from './helpers.easing';
export * from './helpers.extras';
export * from './helpers.interpolation'; | true |
Other | chartjs | Chart.js | 41612d1320db0fcdd08da9cab550ca2deb3a418f.json | Convert the curve helpers to TS (#10733)
* Convert the curve helpers to TS
* Remove old type | types/helpers/helpers.curve.d.ts | @@ -1,34 +0,0 @@
-export interface SplinePoint {
- x: number;
- y: number;
-}
-
-/**
- * Props to Rob Spencer at scaled innovation for his post on splining between points
- * http://scaledinnovation.com/analytics/splines/aboutSplines.html
- */
-export function splineCurve(
- firstPoint: SplinePoint & { skip?: boolean },
- middlePoint: SplinePoint,
- afterPoint: SplinePoint,
- t: number
-): {
- previous: SplinePoint;
- next: SplinePoint;
-};
-
-export interface MonotoneSplinePoint extends SplinePoint {
- skip: boolean;
- cp1x?: number;
- cp1y?: number;
- cp2x?: number;
- cp2y?: number;
-}
-
-/**
- * This function calculates Bézier control points in a similar way than |splineCurve|,
- * but preserves monotonicity of the provided data and ensures no local extremums are added
- * between the dataset discrete points due to the interpolation.
- * @see https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
- */
-export function splineCurveMonotone(points: readonly MonotoneSplinePoint[], indexAxis?: 'x' | 'y'): void; | true |
Other | chartjs | Chart.js | 41612d1320db0fcdd08da9cab550ca2deb3a418f.json | Convert the curve helpers to TS (#10733)
* Convert the curve helpers to TS
* Remove old type | types/helpers/index.d.ts | @@ -1,5 +1,4 @@
export * from './helpers.canvas';
-export * from './helpers.curve';
export * from './helpers.dom';
export * from './helpers.options';
export * from './helpers.canvas'; | true |
Other | chartjs | Chart.js | 06bbadb00f0a79ff1d4f44a3b76c702d090b485d.json | Convert the PointElement to TS (#10730)
Co-authored-by: Chart.js <> | src/core/core.element.ts | @@ -28,8 +28,8 @@ export default class Element<T = AnyObject, O = AnyObject> {
* @param props - properties to get
* @param [final] - get the final value (animation target)
*/
- getProps<P extends string>(props: P[], final?: boolean): Partial<Record<P, unknown>>;
getProps<P extends (keyof T)[]>(props: P, final?: boolean): Pick<T, P[number]>;
+ getProps<P extends string>(props: P[], final?: boolean): Partial<Record<P, unknown>>;
getProps(props: string[], final?: boolean): Partial<Record<string, unknown>> {
const anims = this.$animations;
if (!final || !anims) { | true |
Other | chartjs | Chart.js | 06bbadb00f0a79ff1d4f44a3b76c702d090b485d.json | Convert the PointElement to TS (#10730)
Co-authored-by: Chart.js <> | src/elements/element.arc.js | @@ -311,6 +311,7 @@ export default class ArcElement extends Element {
* @param {boolean} [useFinalPosition]
*/
inRange(chartX, chartY, useFinalPosition) {
+ // @ts-ignore This will be fixed when the arc element is converted to TS
const point = /** @type {Point} */ (this.getProps(['x', 'y'], useFinalPosition));
const {angle, distance} = getAngleFromPoint(point, {x: chartX, y: chartY});
const {startAngle, endAngle, innerRadius, outerRadius, circumference} = /** @type {ArcProps} */ (this.getProps([ | true |
Other | chartjs | Chart.js | 06bbadb00f0a79ff1d4f44a3b76c702d090b485d.json | Convert the PointElement to TS (#10730)
Co-authored-by: Chart.js <> | src/elements/element.point.ts | @@ -1,17 +1,30 @@
import Element from '../core/core.element';
import {drawPoint, _isPointInArea} from '../helpers/helpers.canvas';
-
-function inRange(el, pos, axis, useFinalPosition) {
+import {
+ type CartesianParsedData,
+ type ChartArea,
+ type Point,
+ type PointHoverOptions,
+ type PointOptions,
+} from '../../types';
+
+function inRange(el: PointElement, pos: number, axis: 'x' | 'y', useFinalPosition?: boolean) {
const options = el.options;
const {[axis]: value} = el.getProps([axis], useFinalPosition);
return (Math.abs(pos - value) < options.radius + options.hitRadius);
}
-export default class PointElement extends Element {
+export type PointProps = Point
+
+export default class PointElement extends Element<PointProps, PointOptions & PointHoverOptions> {
static id = 'point';
+ parsed: CartesianParsedData;
+ skip?: boolean;
+ stop?: boolean;
+
/**
* @type {any}
*/
@@ -46,34 +59,34 @@ export default class PointElement extends Element {
}
}
- inRange(mouseX, mouseY, useFinalPosition) {
+ inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean) {
const options = this.options;
- const {x, y} = /** @type {{ x: number, y: number }} */ (this.getProps(['x', 'y'], useFinalPosition));
+ const {x, y} = this.getProps(['x', 'y'], useFinalPosition);
return ((Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2)) < Math.pow(options.hitRadius + options.radius, 2));
}
- inXRange(mouseX, useFinalPosition) {
+ inXRange(mouseX: number, useFinalPosition?: boolean) {
return inRange(this, mouseX, 'x', useFinalPosition);
}
- inYRange(mouseY, useFinalPosition) {
+ inYRange(mouseY: number, useFinalPosition?: boolean) {
return inRange(this, mouseY, 'y', useFinalPosition);
}
- getCenterPoint(useFinalPosition) {
+ getCenterPoint(useFinalPosition?: boolean) {
const {x, y} = this.getProps(['x', 'y'], useFinalPosition);
return {x, y};
}
- size(options) {
+ size(options?: Partial<PointOptions & PointHoverOptions>) {
options = options || this.options || {};
let radius = options.radius || 0;
radius = Math.max(radius, radius && options.hoverRadius || 0);
const borderWidth = radius && options.borderWidth || 0;
return (radius + borderWidth) * 2;
}
- draw(ctx, area) {
+ draw(ctx: CanvasRenderingContext2D, area: ChartArea) {
const options = this.options;
if (this.skip || options.radius < 0.1 || !_isPointInArea(this, area, this.size(options) / 2)) {
@@ -88,6 +101,7 @@ export default class PointElement extends Element {
getRange() {
const options = this.options || {};
+ // @ts-expect-error Fallbacks should never be hit in practice
return options.radius + options.hitRadius;
}
} | true |
Other | chartjs | Chart.js | 06bbadb00f0a79ff1d4f44a3b76c702d090b485d.json | Convert the PointElement to TS (#10730)
Co-authored-by: Chart.js <> | types/index.d.ts | @@ -1,6 +1,7 @@
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils';
import { TimeUnit } from '../src/core/core.adapters';
+import PointElement from '../src/elements/element.point';
import { EasingFunction } from '../src/helpers/helpers.easing';
import { AnimationEvent } from './animation';
import { AnyObject, EmptyObject } from './basic';
@@ -10,6 +11,7 @@ import { ChartArea, Padding, Point } from './geometric';
import { LayoutItem, LayoutPosition } from './layout';
export { EasingFunction } from '../src/helpers/helpers.easing';
+export { default as PointElement, PointProps } from '../src/elements/element.point';
export { Animation, Animations, Animator, AnimationEvent } from './animation';
export { Color } from './color';
export { ChartArea, Point } from './geometric';
@@ -1821,8 +1823,6 @@ export declare const LineElement: ChartComponent & {
new (cfg: AnyObject): LineElement;
};
-export interface PointProps extends Point {}
-
export type PointStyle =
| 'circle'
| 'cross'
@@ -1923,18 +1923,6 @@ export interface PointPrefixedHoverOptions {
pointHoverRadius: number;
}
-export interface PointElement<T extends PointProps = PointProps, O extends PointOptions = PointOptions>
- extends Element<T, O>,
- VisualElement {
- readonly skip: boolean;
- readonly parsed: CartesianParsedData;
-}
-
-export declare const PointElement: ChartComponent & {
- prototype: PointElement;
- new (cfg: AnyObject): PointElement;
-};
-
export interface BarProps extends Point {
base: number;
horizontal: boolean;
@@ -3477,7 +3465,7 @@ export interface ScaleTypeRegistry extends CartesianScaleTypeRegistry, RadialSca
export type ScaleType = keyof ScaleTypeRegistry;
-interface CartesianParsedData extends Point {
+export interface CartesianParsedData extends Point {
// Only specified when stacked bars are enabled
_stacks?: {
// Key is the stack ID which is generally the axis ID | true |
Other | chartjs | Chart.js | e6892a92cba764b5c032e30d31393313e05b1031.json | Convert helpers.extra to TS (#10728)
Co-authored-by: Chart.js <> | src/helpers/helpers.extras.ts | @@ -1,7 +1,9 @@
+import {type ChartMeta, type PointElement} from '../../types';
+
import {_limitValue} from './helpers.math';
import {_lookupByKey} from './helpers.collection';
-export function fontString(pixelSize, fontStyle, fontFamily) {
+export function fontString(pixelSize: number, fontStyle: string, fontFamily: string) {
return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;
}
@@ -20,18 +22,14 @@ export const requestAnimFrame = (function() {
/**
* Throttles calling `fn` once per animation frame
* Latest arguments are used on the actual call
- * @param {function} fn
- * @param {*} thisArg
- * @param {function} [updateFn]
*/
-export function throttled(fn, thisArg, updateFn) {
- const updateArgs = updateFn || ((args) => Array.prototype.slice.call(args));
+export function throttled<TArgs extends Array<any>>(
+ fn: (...args: TArgs) => void,
+ thisArg: any,
+) {
let ticking = false;
- let args = [];
-
- return function(...rest) {
- args = updateArgs(rest);
+ return function(...args: TArgs) {
if (!ticking) {
ticking = true;
requestAnimFrame.call(window, () => {
@@ -44,61 +42,46 @@ export function throttled(fn, thisArg, updateFn) {
/**
* Debounces calling `fn` for `delay` ms
- * @param {function} fn - Function to call.
- * @param {number} delay - Delay in ms. 0 = immediate invocation.
- * @returns {function}
*/
-export function debounce(fn, delay) {
+export function debounce<TArgs extends Array<any>>(fn: (...args: TArgs) => void, delay: number) {
let timeout;
- return function(...args) {
+ return function(...args: TArgs) {
if (delay) {
clearTimeout(timeout);
timeout = setTimeout(fn, delay, args);
} else {
- fn.apply(this, args);
+ fn.apply<any, TArgs, void>(this, args);
}
return delay;
};
}
/**
* Converts 'start' to 'left', 'end' to 'right' and others to 'center'
- * @param {string} align start, end, center
* @private
*/
-export const _toLeftRightCenter = (align) => align === 'start' ? 'left' : align === 'end' ? 'right' : 'center';
+export const _toLeftRightCenter = (align: 'start' | 'end' | 'center') => align === 'start' ? 'left' : align === 'end' ? 'right' : 'center';
/**
* Returns `start`, `end` or `(start + end) / 2` depending on `align`. Defaults to `center`
- * @param {string} align start, end, center
- * @param {number} start value for start
- * @param {number} end value for end
* @private
*/
-export const _alignStartEnd = (align, start, end) => align === 'start' ? start : align === 'end' ? end : (start + end) / 2;
+export const _alignStartEnd = (align: 'start' | 'end' | 'center', start: number, end: number) => align === 'start' ? start : align === 'end' ? end : (start + end) / 2;
/**
* Returns `left`, `right` or `(left + right) / 2` depending on `align`. Defaults to `left`
- * @param {string} align start, end, center
- * @param {number} left value for start
- * @param {number} right value for end
- * @param {boolean} rtl Is this an RTL draw
* @private
*/
-export const _textX = (align, left, right, rtl) => {
+export const _textX = (align: 'left' | 'right' | 'center', left: number, right: number, rtl: boolean) => {
const check = rtl ? 'left' : 'right';
return align === check ? right : align === 'center' ? (left + right) / 2 : left;
};
/**
* Return start and count of visible points.
- * @param {object} meta - dataset meta.
- * @param {array} points - array of point elements.
- * @param {boolean} animationsDisabled - if true animation is disabled.
- * @returns {{start: number; count: number}}
* @private
*/
-export function _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled) {
+export function _getStartAndCountOfVisiblePoints(meta: ChartMeta<'line' | 'scatter'>, points: PointElement[], animationsDisabled: boolean) {
const pointCount = points.length;
let start = 0;
@@ -111,13 +94,17 @@ export function _getStartAndCountOfVisiblePoints(meta, points, animationsDisable
if (minDefined) {
start = _limitValue(Math.min(
+ // @ts-expect-error Need to type _parsed
_lookupByKey(_parsed, iScale.axis, min).lo,
+ // @ts-expect-error Need to fix types on _lookupByKey
animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo),
0, pointCount - 1);
}
if (maxDefined) {
count = _limitValue(Math.max(
+ // @ts-expect-error Need to type _parsed
_lookupByKey(_parsed, iScale.axis, max, true).hi + 1,
+ // @ts-expect-error Need to fix types on _lookupByKey
animationsDisabled ? 0 : _lookupByKey(points, axis, iScale.getPixelForValue(max), true).hi + 1),
start, pointCount) - start;
} else { | true |
Other | chartjs | Chart.js | e6892a92cba764b5c032e30d31393313e05b1031.json | Convert helpers.extra to TS (#10728)
Co-authored-by: Chart.js <> | src/helpers/types.ts | @@ -8,6 +8,7 @@ export * from './helpers.color';
export * from './helpers.collection';
export * from './helpers.core';
export * from './helpers.easing';
+export * from './helpers.extras';
export * from './helpers.interpolation';
export * from './helpers.intl';
export * from './helpers.math'; | true |
Other | chartjs | Chart.js | e6892a92cba764b5c032e30d31393313e05b1031.json | Convert helpers.extra to TS (#10728)
Co-authored-by: Chart.js <> | src/platform/platform.dom.js | @@ -242,10 +242,7 @@ function createProxyAndListen(chart, type, listener) {
if (chart.ctx !== null) {
listener(fromNativeEvent(event, chart));
}
- }, chart, (args) => {
- const event = args[0];
- return [event, event.offsetX, event.offsetY];
- });
+ }, chart);
addListener(canvas, type, proxy);
| true |
Other | chartjs | Chart.js | e6892a92cba764b5c032e30d31393313e05b1031.json | Convert helpers.extra to TS (#10728)
Co-authored-by: Chart.js <> | types/helpers/helpers.extras.d.ts | @@ -1,23 +0,0 @@
-export function fontString(pixelSize: number, fontStyle: string, fontFamily: string): string;
-
-/**
- * Request animation polyfill
- */
-export function requestAnimFrame(cb: () => void): void;
-
-/**
- * Throttles calling `fn` once per animation frame
- * Latest arguments are used on the actual call
- * @param {function} fn
- * @param {*} thisArg
- * @param {function} [updateFn]
- */
-export function throttled(fn: (...args: unknown[]) => void, thisArg: unknown, updateFn?: (...args: unknown[]) => unknown[]): (...args: unknown[]) => void;
-
-/**
- * Debounces calling `fn` for `delay` ms
- * @param {function} fn - Function to call. No arguments are passed.
- * @param {number} delay - Delay in ms. 0 = immediate invocation.
- * @returns {function}
- */
-export function debounce(fn: () => void, delay: number): () => number; | true |
Other | chartjs | Chart.js | e6892a92cba764b5c032e30d31393313e05b1031.json | Convert helpers.extra to TS (#10728)
Co-authored-by: Chart.js <> | types/helpers/index.d.ts | @@ -1,7 +1,6 @@
export * from './helpers.canvas';
export * from './helpers.curve';
export * from './helpers.dom';
-export * from './helpers.extras';
export * from './helpers.options';
export * from './helpers.canvas';
export * from './helpers.segment'; | true |
Other | chartjs | Chart.js | dea889b980a05a9fff9b9f61a552f4f7221d23f5.json | Add defaults to plugin interface (#10712) | types/index.d.ts | @@ -1093,6 +1093,11 @@ export interface Plugin<TType extends ChartType = ChartType, O = AnyObject> exte
* @since 3.0.0
*/
uninstall?(chart: Chart, args: EmptyObject, options: O): void;
+
+ /**
+ * Default options used in the plugin
+ */
+ defaults?: Partial<O>;
}
export declare type ChartComponentLike = ChartComponent | ChartComponent[] | { [key: string]: ChartComponent } | Plugin | Plugin[]; | false |
Other | chartjs | Chart.js | cc65c2bac28c8779b7d96f69470347fbfd6e2e83.json | Fix autoskip logic (#10663)
* fix autoskip logic
* add test
* fix lint erro
* Update variable name | docs/migration/v4-migration.md | @@ -28,6 +28,7 @@ A number of changes were made to the configuration options passed to the `Chart`
* If the tooltip callback returns `undefined`, then the default callback will be used.
* `maintainAspectRatio` respects container height.
* Time and timeseries scales use `ticks.stepSize` instead of `time.stepSize`, which has been removed.
+* `maxTickslimit` wont be used for the ticks in `autoSkip` if the determined max ticks is less then the `maxTicksLimit`.
#### Type changes
* The order of the `ChartMeta` parameters have been changed from `<Element, DatasetElement, Type>` to `<Type, Element, DatasetElement>`. | true |
Other | chartjs | Chart.js | cc65c2bac28c8779b7d96f69470347fbfd6e2e83.json | Fix autoskip logic (#10663)
* fix autoskip logic
* add test
* fix lint erro
* Update variable name | src/core/core.scale.autoskip.js | @@ -16,7 +16,8 @@ import {_factorize} from '../helpers/helpers.math';
*/
export function autoSkip(scale, ticks) {
const tickOpts = scale.options.ticks;
- const ticksLimit = tickOpts.maxTicksLimit || determineMaxTicks(scale);
+ const determinedMaxTicks = determineMaxTicks(scale);
+ const ticksLimit = Math.min(tickOpts.maxTicksLimit || determinedMaxTicks, determinedMaxTicks);
const majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : [];
const numMajorIndices = majorIndices.length;
const first = majorIndices[0]; | true |
Other | chartjs | Chart.js | cc65c2bac28c8779b7d96f69470347fbfd6e2e83.json | Fix autoskip logic (#10663)
* fix autoskip logic
* add test
* fix lint erro
* Update variable name | test/specs/core.scale.tests.js | @@ -34,12 +34,44 @@ describe('Core.scale', function() {
});
}
+ function getChartBigData(maxTicksLimit) {
+ return window.acquireChart({
+ type: 'line',
+ data: {
+ labels: new Array(300).fill('red'),
+ datasets: [{
+ data: new Array(300).fill(5),
+ }]
+ },
+ options: {
+ scales: {
+ x: {
+ ticks: {
+ autoSkip: true,
+ maxTicksLimit
+ }
+ }
+ }
+ }
+ });
+ }
+
function lastTick(chart) {
var xAxis = chart.scales.x;
var ticks = xAxis.getTicks();
return ticks[ticks.length - 1];
}
+ it('should use autoSkip amount of ticks when maxTicksLimit is set to a larger number as autoSkip calculation', function() {
+ var chart = getChartBigData(300);
+ expect(chart.scales.x.ticks.length).toEqual(20);
+ });
+
+ it('should use maxTicksLimit amount of ticks when maxTicksLimit is set to a smaller number as autoSkip calculation', function() {
+ var chart = getChartBigData(3);
+ expect(chart.scales.x.ticks.length).toEqual(3);
+ });
+
it('should display the last tick if it fits evenly with other ticks', function() {
var chart = getChart({
labels: [ | true |
Other | chartjs | Chart.js | 48fefd92b6dc61345021c6508b23698830ff392f.json | Fix the example of Linear Radial Axis (#5633) | docs/axes/radial/linear.md | @@ -76,14 +76,12 @@ This example sets up a chart with a y axis that creates ticks at `0, 0.5, 1, 1.5
```javascript
let options = {
- scales: {
- yAxes: [{
- ticks: {
- max: 5,
- min: 0,
- stepSize: 0.5
- }
- }]
+ scale: {
+ ticks: {
+ max: 5,
+ min: 0,
+ stepSize: 0.5
+ }
}
};
``` | false |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | docs/charts/bubble.md | @@ -51,6 +51,7 @@ The bubble chart allows a number of properties to be specified for each dataset.
| [`hitRadius`](#interactions) | `Number` | Yes | Yes | `1`
| [`label`](#labeling) | `String` | - | - | `undefined`
| [`pointStyle`](#styling) | `String` | Yes | Yes | `circle`
+| [`rotation`](#styling) | `Number` | Yes | Yes | `0`
| [`radius`](#styling) | `Number` | Yes | Yes | `3`
### Labeling
@@ -67,6 +68,7 @@ The style of each bubble can be controlled with the following properties:
| `borderColor` | bubble border color
| `borderWidth` | bubble border width (in pixels)
| `pointStyle` | bubble [shape style](../configuration/elements#point-styles)
+| `rotation` | bubble rotation (in degrees)
| `radius` | bubble radius (in pixels)
All these values, if `undefined`, fallback to the associated [`elements.point.*`](../configuration/elements.md#point-configuration) options. | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | docs/charts/line.md | @@ -63,6 +63,7 @@ All point* properties can be specified as an array. If these are set to an array
| `pointBorderWidth` | `Number/Number[]` | The width of the point border in pixels.
| `pointRadius` | `Number/Number[]` | The radius of the point shape. If set to 0, the point is not rendered.
| `pointStyle` | `String/String[]/Image/Image[]` | Style of the point. [more...](../configuration/elements#point-styles)
+| `pointRotation` | `Number/Number[]` | The rotation of the point in degrees.
| `pointHitRadius` | `Number/Number[]` | The pixel size of the non-displayed point that reacts to mouse events.
| `pointHoverBackgroundColor` | `Color/Color[]` | Point background color when hovered.
| `pointHoverBorderColor` | `Color/Color[]` | Point border color when hovered. | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | docs/charts/radar.md | @@ -82,6 +82,7 @@ All point* properties can be specified as an array. If these are set to an array
| `pointBorderColor` | `Color/Color[]` | The border color for points.
| `pointBorderWidth` | `Number/Number[]` | The width of the point border in pixels.
| `pointRadius` | `Number/Number[]` | The radius of the point shape. If set to 0, the point is not rendered.
+| `pointRotation` | `Number/Number[]` | The rotation of the point in degrees.
| `pointStyle` | `String/String[]/Image/Image[]` | Style of the point. [more...](#pointstyle)
| `pointHitRadius` | `Number/Number[]` | The pixel size of the non-displayed point that reacts to mouse events.
| `pointHoverBackgroundColor` | `Color/Color[]` | Point background color when hovered. | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | docs/configuration/elements.md | @@ -19,6 +19,7 @@ Global point options: `Chart.defaults.global.elements.point`
| -----| ---- | --------| -----------
| `radius` | `Number` | `3` | Point radius.
| [`pointStyle`](#point-styles) | `String` | `circle` | Point style.
+| `rotation` | `Number` | `0` | Point rotation (in degrees).
| `backgroundColor` | `Color` | `'rgba(0,0,0,0.1)'` | Point fill color.
| `borderWidth` | `Number` | `1` | Point stroke width.
| `borderColor` | `Color` | `'rgba(0,0,0,0.1)'` | Point stroke color. | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | src/controllers/controller.bubble.js | @@ -87,6 +87,7 @@ module.exports = function(Chart) {
borderWidth: options.borderWidth,
hitRadius: options.hitRadius,
pointStyle: options.pointStyle,
+ rotation: options.rotation,
radius: reset ? 0 : options.radius,
skip: custom.skip || isNaN(x) || isNaN(y),
x: x,
@@ -146,7 +147,8 @@ module.exports = function(Chart) {
'hoverBorderWidth',
'hoverRadius',
'hitRadius',
- 'pointStyle'
+ 'pointStyle',
+ 'rotation'
];
for (i = 0, ilen = keys.length; i < ilen; ++i) {
@@ -165,7 +167,6 @@ module.exports = function(Chart) {
dataset.radius,
options.radius
], context, index);
-
return values;
}
}); | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | src/controllers/controller.line.js | @@ -148,6 +148,19 @@ module.exports = function(Chart) {
return borderWidth;
},
+ getPointRotation: function(point, index) {
+ var pointRotation = this.chart.options.elements.point.rotation;
+ var dataset = this.getDataset();
+ var custom = point.custom || {};
+
+ if (!isNaN(custom.rotation)) {
+ pointRotation = custom.rotation;
+ } else if (!isNaN(dataset.pointRotation) || helpers.isArray(dataset.pointRotation)) {
+ pointRotation = helpers.valueAtIndexOrDefault(dataset.pointRotation, index, pointRotation);
+ }
+ return pointRotation;
+ },
+
updateElement: function(point, index, reset) {
var me = this;
var meta = me.getMeta();
@@ -185,6 +198,7 @@ module.exports = function(Chart) {
// Appearance
radius: custom.radius || helpers.valueAtIndexOrDefault(dataset.pointRadius, index, pointOptions.radius),
pointStyle: custom.pointStyle || helpers.valueAtIndexOrDefault(dataset.pointStyle, index, pointOptions.pointStyle),
+ rotation: me.getPointRotation(point, index),
backgroundColor: me.getPointBackgroundColor(point, index),
borderColor: me.getPointBorderColor(point, index),
borderWidth: me.getPointBorderWidth(point, index), | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | src/controllers/controller.radar.js | @@ -106,6 +106,7 @@ module.exports = function(Chart) {
borderColor: custom.borderColor ? custom.borderColor : helpers.valueAtIndexOrDefault(dataset.pointBorderColor, index, pointElementOptions.borderColor),
borderWidth: custom.borderWidth ? custom.borderWidth : helpers.valueAtIndexOrDefault(dataset.pointBorderWidth, index, pointElementOptions.borderWidth),
pointStyle: custom.pointStyle ? custom.pointStyle : helpers.valueAtIndexOrDefault(dataset.pointStyle, index, pointElementOptions.pointStyle),
+ rotation: custom.rotation ? custom.rotation : helpers.valueAtIndexOrDefault(dataset.pointRotation, index, pointElementOptions.rotation),
// Tooltip
hitRadius: custom.hitRadius ? custom.hitRadius : helpers.valueAtIndexOrDefault(dataset.pointHitRadius, index, pointElementOptions.hitRadius) | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | src/elements/element.point.js | @@ -68,6 +68,7 @@ module.exports = Element.extend({
var model = this._model;
var ctx = this._chart.ctx;
var pointStyle = vm.pointStyle;
+ var rotation = vm.rotation;
var radius = vm.radius;
var x = vm.x;
var y = vm.y;
@@ -82,7 +83,7 @@ module.exports = Element.extend({
ctx.strokeStyle = vm.borderColor || defaultColor;
ctx.lineWidth = helpers.valueOrDefault(vm.borderWidth, defaults.global.elements.point.borderWidth);
ctx.fillStyle = vm.backgroundColor || defaultColor;
- helpers.canvas.drawPoint(ctx, pointStyle, radius, x, y);
+ helpers.canvas.drawPoint(ctx, pointStyle, radius, x, y, rotation);
}
}
}); | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | src/helpers/helpers.canvas.js | @@ -46,8 +46,9 @@ var exports = module.exports = {
}
},
- drawPoint: function(ctx, style, radius, x, y) {
+ drawPoint: function(ctx, style, radius, x, y, rotation) {
var type, edgeLength, xOffset, yOffset, height, size;
+ rotation = rotation || 0;
if (style && typeof style === 'object') {
type = style.toString();
@@ -61,34 +62,38 @@ var exports = module.exports = {
return;
}
+ ctx.save();
+ ctx.translate(x, y);
+ ctx.rotate(rotation * Math.PI / 180);
+
switch (style) {
// Default includes circle
default:
ctx.beginPath();
- ctx.arc(x, y, radius, 0, Math.PI * 2);
+ ctx.arc(0, 0, radius, 0, Math.PI * 2);
ctx.closePath();
ctx.fill();
break;
case 'triangle':
ctx.beginPath();
edgeLength = 3 * radius / Math.sqrt(3);
height = edgeLength * Math.sqrt(3) / 2;
- ctx.moveTo(x - edgeLength / 2, y + height / 3);
- ctx.lineTo(x + edgeLength / 2, y + height / 3);
- ctx.lineTo(x, y - 2 * height / 3);
+ ctx.moveTo(-edgeLength / 2, height / 3);
+ ctx.lineTo(edgeLength / 2, height / 3);
+ ctx.lineTo(0, -2 * height / 3);
ctx.closePath();
ctx.fill();
break;
case 'rect':
size = 1 / Math.SQRT2 * radius;
ctx.beginPath();
- ctx.fillRect(x - size, y - size, 2 * size, 2 * size);
- ctx.strokeRect(x - size, y - size, 2 * size, 2 * size);
+ ctx.fillRect(-size, -size, 2 * size, 2 * size);
+ ctx.strokeRect(-size, -size, 2 * size, 2 * size);
break;
case 'rectRounded':
var offset = radius / Math.SQRT2;
- var leftX = x - offset;
- var topY = y - offset;
+ var leftX = -offset;
+ var topY = -offset;
var sideSize = Math.SQRT2 * radius;
ctx.beginPath();
@@ -104,60 +109,61 @@ var exports = module.exports = {
case 'rectRot':
size = 1 / Math.SQRT2 * radius;
ctx.beginPath();
- ctx.moveTo(x - size, y);
- ctx.lineTo(x, y + size);
- ctx.lineTo(x + size, y);
- ctx.lineTo(x, y - size);
+ ctx.moveTo(-size, 0);
+ ctx.lineTo(0, size);
+ ctx.lineTo(size, 0);
+ ctx.lineTo(0, -size);
ctx.closePath();
ctx.fill();
break;
case 'cross':
ctx.beginPath();
- ctx.moveTo(x, y + radius);
- ctx.lineTo(x, y - radius);
- ctx.moveTo(x - radius, y);
- ctx.lineTo(x + radius, y);
+ ctx.moveTo(0, radius);
+ ctx.lineTo(0, -radius);
+ ctx.moveTo(-radius, 0);
+ ctx.lineTo(radius, 0);
ctx.closePath();
break;
case 'crossRot':
ctx.beginPath();
xOffset = Math.cos(Math.PI / 4) * radius;
yOffset = Math.sin(Math.PI / 4) * radius;
- ctx.moveTo(x - xOffset, y - yOffset);
- ctx.lineTo(x + xOffset, y + yOffset);
- ctx.moveTo(x - xOffset, y + yOffset);
- ctx.lineTo(x + xOffset, y - yOffset);
+ ctx.moveTo(-xOffset, -yOffset);
+ ctx.lineTo(xOffset, yOffset);
+ ctx.moveTo(-xOffset, yOffset);
+ ctx.lineTo(xOffset, -yOffset);
ctx.closePath();
break;
case 'star':
ctx.beginPath();
- ctx.moveTo(x, y + radius);
- ctx.lineTo(x, y - radius);
- ctx.moveTo(x - radius, y);
- ctx.lineTo(x + radius, y);
+ ctx.moveTo(0, radius);
+ ctx.lineTo(0, -radius);
+ ctx.moveTo(-radius, 0);
+ ctx.lineTo(radius, 0);
xOffset = Math.cos(Math.PI / 4) * radius;
yOffset = Math.sin(Math.PI / 4) * radius;
- ctx.moveTo(x - xOffset, y - yOffset);
- ctx.lineTo(x + xOffset, y + yOffset);
- ctx.moveTo(x - xOffset, y + yOffset);
- ctx.lineTo(x + xOffset, y - yOffset);
+ ctx.moveTo(-xOffset, -yOffset);
+ ctx.lineTo(xOffset, yOffset);
+ ctx.moveTo(-xOffset, yOffset);
+ ctx.lineTo(xOffset, -yOffset);
ctx.closePath();
break;
case 'line':
ctx.beginPath();
- ctx.moveTo(x - radius, y);
- ctx.lineTo(x + radius, y);
+ ctx.moveTo(-radius, 0);
+ ctx.lineTo(radius, 0);
ctx.closePath();
break;
case 'dash':
ctx.beginPath();
- ctx.moveTo(x, y);
- ctx.lineTo(x + radius, y);
+ ctx.moveTo(0, 0);
+ ctx.lineTo(radius, 0);
ctx.closePath();
break;
}
ctx.stroke();
+ ctx.restore();
},
clipArea: function(ctx, area) { | true |
Other | chartjs | Chart.js | 0ddd0ee16b98bad17756a6b98b2460a04fac9056.json | Enable arbitrary rotation of datapoints (#5319) | test/specs/element.point.tests.js | @@ -108,6 +108,7 @@ describe('Point element tests', function() {
point._view = {
radius: 2,
pointStyle: 'circle',
+ rotation: 25,
hitRadius: 3,
borderColor: 'rgba(1, 2, 3, 1)',
borderWidth: 6,
@@ -128,12 +129,21 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'arc',
- args: [10, 15, 2, 0, 2 * Math.PI]
+ args: [0, 0, 2, 0, 2 * Math.PI]
}, {
name: 'closePath',
args: [],
@@ -143,6 +153,9 @@ describe('Point element tests', function() {
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
mockContext.resetCalls();
@@ -158,18 +171,27 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'moveTo',
- args: [10 - 3 * 2 / Math.sqrt(3) / 2, 15 + 3 * 2 / Math.sqrt(3) * Math.sqrt(3) / 2 / 3]
+ args: [0 - 3 * 2 / Math.sqrt(3) / 2, 0 + 3 * 2 / Math.sqrt(3) * Math.sqrt(3) / 2 / 3]
}, {
name: 'lineTo',
- args: [10 + 3 * 2 / Math.sqrt(3) / 2, 15 + 3 * 2 / Math.sqrt(3) * Math.sqrt(3) / 2 / 3],
+ args: [0 + 3 * 2 / Math.sqrt(3) / 2, 0 + 3 * 2 / Math.sqrt(3) * Math.sqrt(3) / 2 / 3],
}, {
name: 'lineTo',
- args: [10, 15 - 2 * 3 * 2 / Math.sqrt(3) * Math.sqrt(3) / 2 / 3],
+ args: [0, 0 - 2 * 3 * 2 / Math.sqrt(3) * Math.sqrt(3) / 2 / 3],
}, {
name: 'closePath',
args: [],
@@ -179,6 +201,9 @@ describe('Point element tests', function() {
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
mockContext.resetCalls();
@@ -194,18 +219,30 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'fillRect',
- args: [10 - 1 / Math.SQRT2 * 2, 15 - 1 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2]
+ args: [0 - 1 / Math.SQRT2 * 2, 0 - 1 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2]
}, {
name: 'strokeRect',
- args: [10 - 1 / Math.SQRT2 * 2, 15 - 1 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2]
+ args: [0 - 1 / Math.SQRT2 * 2, 0 - 1 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2, 2 / Math.SQRT2 * 2]
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
var drawRoundedRectangleSpy = jasmine.createSpy('drawRoundedRectangle');
@@ -218,8 +255,8 @@ describe('Point element tests', function() {
expect(drawRoundedRectangleSpy).toHaveBeenCalledWith(
mockContext,
- 10 - offset,
- 15 - offset,
+ 0 - offset,
+ 0 - offset,
Math.SQRT2 * 2,
Math.SQRT2 * 2,
2 * 0.425
@@ -245,21 +282,30 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'moveTo',
- args: [10 - 1 / Math.SQRT2 * 2, 15]
+ args: [0 - 1 / Math.SQRT2 * 2, 0]
}, {
name: 'lineTo',
- args: [10, 15 + 1 / Math.SQRT2 * 2]
+ args: [0, 0 + 1 / Math.SQRT2 * 2]
}, {
name: 'lineTo',
- args: [10 + 1 / Math.SQRT2 * 2, 15],
+ args: [0 + 1 / Math.SQRT2 * 2, 0],
}, {
name: 'lineTo',
- args: [10, 15 - 1 / Math.SQRT2 * 2],
+ args: [0, 0 - 1 / Math.SQRT2 * 2],
}, {
name: 'closePath',
args: []
@@ -269,6 +315,9 @@ describe('Point element tests', function() {
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
mockContext.resetCalls();
@@ -284,27 +333,39 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'moveTo',
- args: [10, 17]
+ args: [0, 2]
}, {
name: 'lineTo',
- args: [10, 13],
+ args: [0, -2],
}, {
name: 'moveTo',
- args: [8, 15],
+ args: [-2, 0],
}, {
name: 'lineTo',
- args: [12, 15],
+ args: [2, 0],
}, {
name: 'closePath',
args: [],
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
mockContext.resetCalls();
@@ -320,27 +381,39 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'moveTo',
- args: [10 - Math.cos(Math.PI / 4) * 2, 15 - Math.sin(Math.PI / 4) * 2]
+ args: [0 - Math.cos(Math.PI / 4) * 2, 0 - Math.sin(Math.PI / 4) * 2]
}, {
name: 'lineTo',
- args: [10 + Math.cos(Math.PI / 4) * 2, 15 + Math.sin(Math.PI / 4) * 2],
+ args: [0 + Math.cos(Math.PI / 4) * 2, 0 + Math.sin(Math.PI / 4) * 2],
}, {
name: 'moveTo',
- args: [10 - Math.cos(Math.PI / 4) * 2, 15 + Math.sin(Math.PI / 4) * 2],
+ args: [0 - Math.cos(Math.PI / 4) * 2, 0 + Math.sin(Math.PI / 4) * 2],
}, {
name: 'lineTo',
- args: [10 + Math.cos(Math.PI / 4) * 2, 15 - Math.sin(Math.PI / 4) * 2],
+ args: [0 + Math.cos(Math.PI / 4) * 2, 0 - Math.sin(Math.PI / 4) * 2],
}, {
name: 'closePath',
args: [],
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
mockContext.resetCalls();
@@ -356,39 +429,51 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'moveTo',
- args: [10, 17]
+ args: [0, 2]
}, {
name: 'lineTo',
- args: [10, 13],
+ args: [0, -2],
}, {
name: 'moveTo',
- args: [8, 15],
+ args: [-2, 0],
}, {
name: 'lineTo',
- args: [12, 15],
+ args: [2, 0],
}, {
name: 'moveTo',
- args: [10 - Math.cos(Math.PI / 4) * 2, 15 - Math.sin(Math.PI / 4) * 2]
+ args: [0 - Math.cos(Math.PI / 4) * 2, 0 - Math.sin(Math.PI / 4) * 2]
}, {
name: 'lineTo',
- args: [10 + Math.cos(Math.PI / 4) * 2, 15 + Math.sin(Math.PI / 4) * 2],
+ args: [0 + Math.cos(Math.PI / 4) * 2, 0 + Math.sin(Math.PI / 4) * 2],
}, {
name: 'moveTo',
- args: [10 - Math.cos(Math.PI / 4) * 2, 15 + Math.sin(Math.PI / 4) * 2],
+ args: [0 - Math.cos(Math.PI / 4) * 2, 0 + Math.sin(Math.PI / 4) * 2],
}, {
name: 'lineTo',
- args: [10 + Math.cos(Math.PI / 4) * 2, 15 - Math.sin(Math.PI / 4) * 2],
+ args: [0 + Math.cos(Math.PI / 4) * 2, 0 - Math.sin(Math.PI / 4) * 2],
}, {
name: 'closePath',
args: [],
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
mockContext.resetCalls();
@@ -404,21 +489,33 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'moveTo',
- args: [8, 15]
+ args: [-2, 0]
}, {
name: 'lineTo',
- args: [12, 15],
+ args: [2, 0],
}, {
name: 'closePath',
args: [],
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
mockContext.resetCalls();
@@ -434,21 +531,33 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0, 255, 0)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [25 * Math.PI / 180]
}, {
name: 'beginPath',
args: []
}, {
name: 'moveTo',
- args: [10, 15]
+ args: [0, 0]
}, {
name: 'lineTo',
- args: [12, 15],
+ args: [2, 0],
}, {
name: 'closePath',
args: [],
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
});
@@ -483,12 +592,21 @@ describe('Point element tests', function() {
}, {
name: 'setFillStyle',
args: ['rgba(0,0,0,0.1)']
+ }, {
+ name: 'save',
+ args: []
+ }, {
+ name: 'translate',
+ args: [10, 15]
+ }, {
+ name: 'rotate',
+ args: [0]
}, {
name: 'beginPath',
args: []
}, {
name: 'arc',
- args: [10, 15, 2, 0, 2 * Math.PI]
+ args: [0, 0, 2, 0, 2 * Math.PI]
}, {
name: 'closePath',
args: [],
@@ -498,6 +616,9 @@ describe('Point element tests', function() {
}, {
name: 'stroke',
args: []
+ }, {
+ name: 'restore',
+ args: []
}]);
});
| true |
Other | chartjs | Chart.js | 387a23df737fcf8d0faf8762b757b2a428c5a906.json | Add support for Shadow DOM (#5585)
https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/host | src/core/core.helpers.js | @@ -450,7 +450,7 @@ module.exports = function() {
// @see http://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser
function getConstraintDimension(domNode, maxStyle, percentageProperty) {
var view = document.defaultView;
- var parentNode = domNode.parentNode;
+ var parentNode = helpers._getParentNode(domNode);
var constrainedNode = view.getComputedStyle(domNode)[maxStyle];
var constrainedContainer = view.getComputedStyle(parentNode)[maxStyle];
var hasCNode = isConstrainedValue(constrainedNode);
@@ -481,8 +481,18 @@ module.exports = function() {
return padding.indexOf('%') > -1 ? parentDimension / parseInt(padding, 10) : parseInt(padding, 10);
};
+ /**
+ * @private
+ */
+ helpers._getParentNode = function(domNode) {
+ var parent = domNode.parentNode;
+ if (parent && parent.host) {
+ parent = parent.host;
+ }
+ return parent;
+ };
helpers.getMaximumWidth = function(domNode) {
- var container = domNode.parentNode;
+ var container = helpers._getParentNode(domNode);
if (!container) {
return domNode.clientWidth;
}
@@ -496,7 +506,7 @@ module.exports = function() {
return isNaN(cw) ? w : Math.min(w, cw);
};
helpers.getMaximumHeight = function(domNode) {
- var container = domNode.parentNode;
+ var container = helpers._getParentNode(domNode);
if (!container) {
return domNode.clientHeight;
} | true |
Other | chartjs | Chart.js | 387a23df737fcf8d0faf8762b757b2a428c5a906.json | Add support for Shadow DOM (#5585)
https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/host | test/specs/core.helpers.tests.js | @@ -568,6 +568,31 @@ describe('Core helper tests', function() {
document.body.removeChild(div);
});
+ it ('should get the maximum width and height for a node in a ShadowRoot', function() {
+ // Create div with fixed size as a test bed
+ var div = document.createElement('div');
+ div.style.width = '200px';
+ div.style.height = '300px';
+
+ document.body.appendChild(div);
+
+ if (!div.attachShadow) {
+ // Shadow DOM is not natively supported
+ return;
+ }
+
+ var shadow = div.attachShadow({mode: 'closed'});
+
+ // Create the div we want to get the max size for
+ var innerDiv = document.createElement('div');
+ shadow.appendChild(innerDiv);
+
+ expect(helpers.getMaximumWidth(innerDiv)).toBe(200);
+ expect(helpers.getMaximumHeight(innerDiv)).toBe(300);
+
+ document.body.removeChild(div);
+ });
+
it ('should get the maximum width of a node that has a max-width style', function() {
// Create div with fixed size as a test bed
var div = document.createElement('div'); | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.